Open yarelm opened 3 years ago
Most metrics libraries have flush() methods that can be called before container shuts down via a SIGTERM signal. Consider using that facility.
There's a feature in preview that keeps the CPU always on in the background but it has different pricing and not publicly available yet.
I'm guessing that CPU throttling is different to terminating the process? But I don't see much document about what people should do in a process being throttled or "suspended". To be more specific I personally have no idea what to do with DB connection pools.
BTW the "always allocate CPU" flag is in GA now.
Hya, Using Cloud Run (in Go for example), occasionally there is a need to use a 3rd party pkg that does some background processing. Sometimes, this processing is done out of the request context.
For example, I'm using the (https://github.com/google/go-metrics-stackdriver) pkg for sending metrics to stackdriver. It launches a goroutine that periodically sends pending metrics. This is done async to the request flow.
I understand Cloud Run can throttle the CPU to 0 when not handling requests - I am intrigued about how does that affects such use cases. In some cases, I can be OK with my periodic handling being suspended for a while. Just trying to better understand what to expect.
I know the best practice is to avoid background jobs, however, I believe in many use cases it's a requirement (I prefer to not re-write plumbing logic when I don't have to 😄 )
Cheers