Hi Ian, Thanks for the link and answering. I'll look more into understanding the issue. I'm mostly trying to reconcile that there are so many articles about not using Java inside containers because it does nothing to stay in the memory limits, but then I see no other articles about Go, giving the appearance it plays well with container memory limits. Maybe Go's garbage collector is more aggressive at keeping memory usage down?
In regards to CPU, I was running an app in a Kubernetes cluster on a node that had 16 CPUs. Even if I limited the apps access to 1 CPU, the runtime.NumCPU() call still returned 16. Leigh On Wednesday, September 12, 2018 at 6:46:34 AM UTC-7, Ian Lance Taylor wrote: > > On Tue, Sep 11, 2018 at 11:48 PM, Leigh McCulloch <leig...@gmail.com > <javascript:>> wrote: > > > > Does anyone here know how Go interacts with memory limits inside > containers? (e.g. Kubernetes, Docker) > > > > Does the Go runtime have similar problems as the Java runtime, in that > it doesn't know what the container limit is, and only knows what the > physical limit is for the entire instance? > > > > Or is Go aware of limits placed on the container? > > > > (I've witnessed the Go runtime package say the NumCPU is the total > physical count when the app has been limited to many less CPUs, so it seems > like it doesn't have visibility into the CPU limitations.) > > As far as I know, the current implementations of Go don't pay > attention to memory limits at all, whether running inside a container > or not. You may be interested in following > https://golang.org/issue/23044 which could be a first step toward > fixing this. In some sense the core issue is that using memory limits > in a garbage collected language is close to useless if the program > doesn't have a way to react when heap size is nearing the memory > limit. > > On the other hand, on GNU/Linux systems, the CPU count is determined > by calling the sched_getaffinity system call, which as far as I know > is aware of container limits. What leads you to believe otherwise? > > Ian > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.