I'm developing a platform where multiple users can run their own Python trading bots in Docker containers. Currently, each user has 3 strategies running in separate containers, which means I have 30 containers for 10 users. I'm wondering if this is the right way to go about it. I have a React frontend and a Python backend, but I'm encountering some issues. For example, when a user clicks to stop all their strategies, the system lags because it has to shut down all their Docker containers at once. Additionally, I'm polling for balances and other information every 30 seconds, which makes the web app feel slow.
I'm looking for advice on how to scale this up to handle 500+ users efficiently. Should I consider a complete redesign of the architecture?
1 Answer
Instead of spawning a separate container for each user, consider load balancing your resources. You might not need a dedicated container for every single user unless they require specific access. If not, think about merging containers that run the same strategies and managing user actions from there. This could help reduce the system overhead and improve your scalability while still maintaining user separation where needed.
You're suggesting each user only have one container, right? So if a user starts a second strategy, we'd stop the first one, save its state, add the new strategy to the container, and restart it? That sounds like a solid approach!