Background task in Kubernetes

11/27/2017

We recently moved from using Google App Engine standard environment to Kubernetes (GKE), while in the standard environment, we used Task queues to run task in the background to reduce latency. I want to do the same on Kubernetes, how do I achieve this since task queue is not available on Kubernetes?

One solution I can think of is to use Threads, but threading is not advised on google cloud. I have also heard about message queues and Kubernetes Executor but I cant seem to get a good resource to walk me through how to achieve backgroud task using them.

Please I need suggestions on this and resource I could read.

-- oziomajnr
google-app-engine
java
kubernetes
multithreading
task

1 Answer

11/28/2017

After little research and Consultation, I have made the following findings and I wish to correct misconceptions I presented in the question.

  1. Threading is not advised on Google Cloud : this statement is true only for the google app engine standard environment where threads cannot live outside the request that created them. So if you have a task that would run for 3 minutes and you place it in a thread, after the request is cut off at the 60 seconds limit, then the thread shuts down. This is the reason why Task Queue and Pub Sub is advised on Google App Engine. However, on Kubernetes and the Google App Engine Flexible Environment, this principle does not hold and thus you can use threads.

So to solve my problem I just used Java Threading managed with executor service.

-- oziomajnr
Source: StackOverflow