SFS2X and database on several machines.

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

direct3d9
Posts: 1
Joined: 20 Jun 2017, 12:10

SFS2X and database on several machines.

Postby direct3d9 » 20 Jun 2017, 12:33

Hi.
We want to implement one login SFS2X server on one machine, and several game servers around the world. All these server will communicate with separate MySQL database server. The main goal of this is to minimize latency in online games.
We have experimented and configured SmartFox and database on separate servers. The ping latency to database server is 100 milliseconds. Later we tried to test this configuration and we figured out what mysql queries is very very slow (several sql select queries, which returns small amount of rows consumes 5-20 seconds). We have read http://www.smartfoxserver.com/forums/viewtopic.php?t=16569 topic, which advises to configure Smartfox and database servers in local network, but this advise not covers our requirements.

Please advise us how to fix this issue. Is it really to implement several game servers with one mysql database? Probably mysql stored procedures will help to minimize this query time? Perhaps exist congiruration which provides fast communication with database?

Thank you in advance.
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: SFS2X and database on several machines.

Postby Lapo » 20 Jun 2017, 14:58

This is a classic issue in scalability.
With a network latency of 100ms your server can only handle 10 requests/sec per thread. Additionally you have to add the MySQL execution time, let's say another 100ms on average.
This gives us 200ms total latency or 5 requests/sec per thread.

SFS2X can handle this bottleneck by spawning more threads as it's necessary to avoid issues. Of course threads are a bit expensive in terms of performance but with a modern hardware, let's at least quad core Xeon with 8GB RAM you should have no problem managing several 1000s of threads, if necessary.

Here's a detailed explanation of how auto load-balancing threads work in SFS2X.
http://docs2x.smartfoxserver.com/Extens ... d-concepts

For your use case you may want to with use a higher Core threads value. Probably 50-60 would be a good start.
Backup threads: 50-60
Maximum backups: 100

This should be enough to keep up with the slowest database around :) Nonetheless, keep in mind that optimizing your network lag and execution times of the DB is paramount. Adding more thread is the last resort.

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 104 guests