Need advises Optimization - infrastructure server

Hey everyone,

I have a wordpress website built with roots/sage9.

The website is a little bit particular, because our client “opens” the website once a week, 6.30pm, until 20 items are sold. It’s pretty faster, because a lot of users are ready to buy.
After 20 items are sold, or when it’s 00.00pm, we block automatically the shopping.

The problem is the infra server, as we didn’t know the flux of users at 6.30pm every week and as the budget of the client was limited, we put the code source on a shared server. Of course, after 3 minutes, the website was down …
Now, we migrated on an a VPS with 2CPU/4Go de ram (handled by a third business party - 40$/month) …

We simulated a test charge with 300 simultaneous users … the server doesn’t seem enough yet.

I can’t evaluate what we need. A lot of people said that wordpress is extremely greedy when there are a lot of users.

The wordpress is classic :

  • woocommerce
  • wpml
  • ACF
  • yoast
  • I just put wp-fatest-cache now.
  • I put google analytics for the next sell to know the realtime user at the opening.

On each page, there is a countdown timer for the next sell + the number item on the cart icon, so I fetch some data through an ajax request to retrieve :

  • nb product in the cart
  • the next opening datetime

I don’t know if i’m very clear with my problem, I think the real problem is the infra.

Thanks for your feedbacks, advises,

Down how? What do the logs say? What exactly happens?

What service / benchmarking-tool did you use? By which metric do you know it is “not enough”?

Can you somehow test the performance of your scripts? Maybe the culprit lies with the increasing number of AJAX requests / database hits…?


The host could not say, just said : PHP process is saturated.

The load test was done by the new hoster, when he ran the test, I could check on its grafana admin.
We saw that the CPU was on 100%. And the load charge increased a lot.

The ajax request hits the database. It’s mandatory to check if the shop is “open” or “close”.

The ajax request calls this function :

  $shopManager = \App\Managers\ShopManager::getInstance();

  echo wp_send_json([
    'nb_products_cart' => WC()->cart->get_cart_contents_count(),
    'shop_informations' => $shopManager->shopInformation

where $shopManager did :

$nextOpeningDateTime = \DateTime::createFromFormat('Y-m-d H:i:s', get_option('mc_next_opening'))
$currentDateTime = new \DateTime();

$isShopOpened = $currentDateTime >= $nextOpeningDateTime;

if($isShopOpened) {
  $this->quantitySold = $this->getQuantitySold(); // SELECT sum(quantity) FROM MYTABLE WHERE completed_payment_date BETWEEN %s AND %s
  $userCanStillPurchase = $this->quantitySold < $this->maxProductsToSell;

  if(!$userCanStillPurchase) { // if max product is achieved, we close the shop
    $openingDay = get_field('mc_opening_day', 'option');
    $openingTime = get_field('mc_opening_hours', 'option');
    $nextOpeningDay = 'Next ' . $openingDay;
    $nextOpeningDateTime = $nextOpeningDateTime->modify($nextOpeningDay);
    $nextOpeningDateTime->setTime($openingTime[0], $openingTime[1]);

return [
  'isOpen' => $userCanStillPurchase ?? $isShopOpened,
  'openingDate' => $nextOpeningDateTime->setTimeZone(new \DateTimeZone('UTC')),
  'currentTime' => $currentDateTime->format('Y-m-d H:i:s')

I’m not sure it’s very clear for you, but it could maybe help you to help me :smile:

You should get / request much more debug info then this – without the detailed error message you’ll loose valuable time debugging (IMHO).

What does the PHP / Nginx config look like?

Did the (v)users actually do anything on the page or just GET the resources? Any server will go down at some point… Since the business revolves around generating / encountering traffic spikes I would also look at caching mechanisms like FastCGI caching.

Have you considered / tried using Trellis at all?

I get the basic setup :slightly_smiling_face: Not sure if you could optimize this but I would look into the other variables (see above) before you do anything with the code…

Anyway, I changed the hosting, becasue of the support.

It’s php 7.2 , mysql 5, apache.

Yes for now, I put a google analytics for the tomorrow selling. To know exactly how much user.
For now, there is just a WP Fatest cache plugin. So yes, we could imagine to add a real cache system.

I was thinking about the detailed specs like max_execution_time etc. – you should look into the settings to see if there is a bottleneck and whether you can tweak / optimize the performance.

Eliminating all the other requests / hits and focusing on the actual shop stuff should prove very useful…



yesterday it was the opening, the server didn’t fall.
4 CPU / 8go de ram, both used at 50%.

at 6.00pm : 342 users
at opening 6.30pm : 220 users …

So it’s not bad as a traffic peak. So continue to optimize, maybe I will use :

  • cdn for images
  • installing opcache. (but i don’t know yet the benefit compared to WP-Fatest-cache)
  • maybe put a queue waiting list to access to the website (but don’t know either yet how it works technically :smiley: … )

I don’t know what to expose you. But if I made SHOW VARIABLES; on mysql :

max_connect_errors : 100
max_connections: 151
max_execution_time: 0
thread_cache_size: 8

If the current server is enough, it could be too expensive in a long term for my client. (so managed server - 75euros+20 for saving system)
The ideal will be to have a scalable server as we know on AWS. But i can’t manage this.
The ideal will be all the week an intermediate lighter server and for the opening day (wednesday) the big one ^^ … but the current hoster can’t do that for now … ^^’

This topic was automatically closed after 42 days. New replies are no longer allowed.