I have kind of an architectural dilemna right now. I’m building a Texas Holdem Poker app and I’m trying to think of a way to scale my stateful server.
The server is in node js and works with Pomelo (a library build on top of Socket.io if I am not mistaken). The server manages all the game logic and is therefore stateful.
I’m thinking about using “cache as a service” solutions like redis but I’m not sure if it would do the job.
I’d really be interested if somebody could give me guidance or refer me to nice articles about this topic. Scaling stateless services is a piece of cake nowadays but their stateful counterpart are (almost) never spoken off.
Thank you!
EDIT: Apparently, this is an opinion based question, so let me reformulate it… How do you scale a stateful socket.io server that maintains the table data (for each poker game) in cache? For now, I have two solutions that come in mind. Either use redis’s pub/sub functionnality, or use a cache as a service provider like amazon’s ElastiCache. Any one can refer me to articles or anything that could help me shed light and understand better this problem?
2
Answers
It’s not clear for me what you application architecture realy is but take a look at thesse two examples:
https://learn.microsoft.com/en-us/samples/azure-samples/scaling-stateful-java-web-app-on-azure/scaling-stateful-apps-java-sample/
https://medium.com/walkme-engineering/horizontal-scaling-of-a-stateful-server-with-redis-pub-sub-fc56c875b1aa
If you are using cloud, the task may be easier.
If you describe more your components, I can try help you.
Which data do you have?
Are using an external DB?
I would use a cache for session persistence, and a DB for long term data, (SQL or NoSQL).
Moving it to these services frees you to move you service to kubernetes or lambda. Because all your application will be stateless.
Regards