So I have a Google Cloud AppEngine server which has 2 main jobs.
- Every Day at 00:00, download lots of data (Firebase/Async), process it, and send out notifications via HTTP, interact with GoogleStorage, etc..
- Listen to different types of requests and send out Notifications via HTTP when received.
So for testing purposes I would just spawn a new thread for every HTTP post or synchronous call in libraries like Google Storage, and while this works, I do not think that this will scale well, and might cause out of memory exceptions.
Im worried that say, there are 1000 post/get requests that need to be made at 00:00, and then if I create 1000 threads, that will cause problems, on the other hand, I could iterate through the requests in a single thread, but then that thread will take a long time to finish.
I thought of using a Executor which has a size of ~10, so that one thread is always available to do the daily processing task, and the other 9 threads are available for any requests that might come in.
Is that a good aproach? Or should the threadpool be dynamically scaled, or queued up?