2a7da21e0db2c5fe1363a984aa802de3c4a02242
By:
sugarhill

shop server scaling / customer peak / database replication

September 17, 2015 1.4k views
Scaling Server Optimization Clustering Load Balancing MariaDB MySQL Debian

I have a small shop (PrestaShop) that only sells 1 item, a show ticket.

This show ticket becomes available after a countdown on my site.
3.000 people are waiting on my webshop to get a ticket and hit refresh button until item becomes available. Then everyone rushes to checkout simultaneously to make purchase. After half an hour it's sold out and things go back to normal.

My current setup:
3.000 people order ---> 48 GB web server (laggy) --> database (lots of write errors)

In this setup I gets lots of uncomplete & duplicate orders. Also I oversell my stock by a couple hundred items before shop displays "sold out"

My setup idea A:
3.000 people order --> 64GB / 20 CPUs web server --> 2x database (master 1 & master 2)

In this setup the shop server has more power and the database has a failsafe (second master). Priority is writing to database without errors (prevent order overload)

My setup idea B:
3.000 people order --> load balancer --> 2x shop server (each 32GB/12 CPU) --> 2x database (master 1 & master 2)
This setup also requires sticky sessions (afaik) and is probably not easy to achieve.

Honestly I have no idea what kind of setup can handle this peak load best.
By law I need SSL for collecting customer details - so this is a must.

I'm open to any suggestions (alternative setups) and/or links to any tutorials to set this up successfully.

2 comments
  • That is a lot of concurrent users, but you may need to look into locking your database writes. That would solve your transactions issues, but this will cause additional demand on your database. Make sure to allocate enough memory for your database, make sure everything else is cached on the site.

    I run a site that has handled around 1500 concurrent users over a few hours, it had a proxy server in front, web server and database server. It would have run faster if the database server was on the same server as the web server.

    You could also look into Redis to help speed things up. I would look at speeding up your site and solving your overselling issue before you jump to more servers.

  • Thanks a lot for your suggestions - some very good tips :)

1 Answer

This question was answered by @jasonruyle:

That is a lot of concurrent users, but you may need to look into locking your database writes. That would solve your transactions issues, but this will cause additional demand on your database. Make sure to allocate enough memory for your database, make sure everything else is cached on the site.

I run a site that has handled around 1500 concurrent users over a few hours, it had a proxy server in front, web server and database server. It would have run faster if the database server was on the same server as the web server.

You could also look into Redis to help speed things up. I would look at speeding up your site and solving your overselling issue before you jump to more servers.

View the original comment

Have another answer? Share your knowledge.