Suggestions on load balancing a WordPress Website

SagnikSSagnikS Hosting ProviderOG

Heya guys,

I host a website (LEMP) which gets a lot of traffic, and the CPU hits a 100% at peak times (even on a dedicated server). So, I'm looking to do a basic load balancing setup, and add another dedicated server to the "cluster".
I tried hosting PHP-FPM on another server, and mounting the directories using NFS, and then load balancing only PHP using NGINX, but the requests were being processed very slowly, also the CPU load was somehow in the 1000s range, however the iowait was very low.
What solution would you suggest to accomplish this?

Thank you :)

Comments

  • WSSWSS OGRetired

    Cache it, static it, or find another publishing product.

    My pronouns are like/subscribe.

  • SagnikSSagnikS Hosting ProviderOG

    @WSS said:
    Cache it, static it, or find another publishing product.

    I wish I could, it's not my website, and migration isn't an option unfortunately. There's Redis Object Caching and CF Caching in place, and the CPU still maxes out inspite of that.

  • havochavoc OGContent Writer
    edited March 2020

    @SagnikS said: the CPU still maxes out inspite of that.

    Throw one of the popular free caching plugins on there. Did that while loadtesting a WP site...dropped CPU usage to near zero

    ...don't recall which one I used, but one of the popular caching ones. Was actually surprised how effective it was

  • SagnikSSagnikS Hosting ProviderOG

    @havoc said:

    @SagnikS said: the CPU still maxes out inspite of that.

    Throw one of the popular free caching plugins on there. Did that while loadtesting a WP site...dropped CPU usage to near zero

    ...don't recall which one I used, but one of the popular caching ones. Was actually surprised how effective it was

    I have, I've spent over a day on this, trying to tweak it, experimenting with caching plugins, etc., it all came down to 1 plugin causing it. The site gets around 12-13k rt visitors at peak, so that might be it as well.

  • WSSWSS OGRetired

    So - kill that plugin and tell them it will cost X to support. WP-SuperCache should handle the majority of needs if the site doesn't get by-the-minute updates.

    My pronouns are like/subscribe.

  • imokimok OG
    edited March 2020

    Move the database to other server and redis to another one, and use w3 total cache. You can also put nginx in front of them as a proxy.
    With Varnish, it will fly.

  • WSSWSS OGRetired

    Then fucking remove PordWress..

    Thanked by (1)FlamingSpaceJunk

    My pronouns are like/subscribe.

  • @SagnikS said:

    @WSS said:
    Cache it, static it, or find another publishing product.

    I wish I could, it's not my website, and migration isn't an option unfortunately. There's Redis Object Caching and CF Caching in place, and the CPU still maxes out inspite of that.

    Why not cache it on Nginx level? Cache the fastcgi response for certain time, so in that time any request received will be served from cache, won't even touch php. Off-course this strategy depends on how much dynamic your site is.

  • @PHP_Backend said:
    Why not cache it on Nginx level? Cache the fastcgi response for certain time, so in that time any request received will be served from cache, won't even touch php. Off-course this strategy depends on how much dynamic your site is.

    I dont know how much is a lot OP referred to. But cache fastcgi really helpfull. I'm able to handle 10x traffic

  • InceptionHostingInceptionHosting Hosting ProviderOG
    edited March 2020

    @SagnikS said: it all came down to 1 plugin causing it.

    Might be worth spending a bit on money on an hour or 5 of quality dev time to look at the plugin, a good dev may be able to spot the issue and tweak it for you @joepie91 @Solaire

    https://inceptionhosting.com
    Please do not use the PM system here for Inception Hosting support issues.

  • SagnikSSagnikS Hosting ProviderOG
    edited March 2020

    @AnthonySmith said:

    @SagnikS said: it all came down to 1 plugin causing it.

    Might be worth spending a bit on money on an hour or 5 of quality dev time to look at the plugin, a good dev may be able to spot the issue and tweak it for you @joepie91 @Solaire

    Yep, I'm trying to convince the website owner about that.

    To the others suggesting NGINX caching etc, that was already in place. The plugin basically embeds videos from multiple video sites (vimeo, YT, etc.), but gets rid of how YT videos look generally (it probably gets the direct link from their CDN). So, for every view, the plugin has to process the request. Caching would be have probably worked if the generated page had a direct link to the video, and not smth like domain.tld/wp-content/plugins/<video-embedder-plugin>/player.php?provider=fb&id=<randomid>.

  • InceptionHostingInceptionHosting Hosting ProviderOG
    edited March 2020

    aaah wow, I used a youtube embedder/grabber plugin on a site about 6 - 7 years ago, it was horrible, in the end I paid someone on freelancer.com about $50 to write a new one for me, if I still had it I would give it to you but that is long gone, it took them no time.

    Thanked by (1)SagnikS

    https://inceptionhosting.com
    Please do not use the PM system here for Inception Hosting support issues.

  • Hah, an youtube grabber?!? Oh that pain.

    However, did you read Nginx docs? They are pretty simple to follow and rich.
    https://docs.nginx.com/nginx/admin-guide/load-balancer/http-load-balancer/
    https://nginx.org/en/docs/http/load_balancing.html

    You just have to make a mirror copy of your current server on new server. Then configure the "load balancing" nginx to proxy pass all incoming request to any of the working servers based on some criteria (round robin, least_connection.. etc)

    the CPU hits a 100% at peak times (even on a dedicated server)

    How much CPU juice your current setup has? I would ensure max strength on my current setup before scaling out.
    Because in my book, less moving parts means simpler architecture and better maintainability. Only scale when you've been maxed out.

  • SagnikSSagnikS Hosting ProviderOG
    edited March 2020

    @PHP_Backend said:
    Hah, an youtube grabber?!? Oh that pain.

    :P

    However, did you read Nginx docs? They are pretty simple to follow and rich.
    https://docs.nginx.com/nginx/admin-guide/load-balancer/http-load-balancer/
    https://nginx.org/en/docs/http/load_balancing.html

    You just have to make a mirror copy of your current server on new server. Then configure the "load balancing" nginx to proxy pass all incoming request to any of the working servers based on some criteria (round robin, least_connection.. etc)

    the CPU hits a 100% at peak times (even on a dedicated server)

    How much CPU juice your current setup has? I would ensure max strength on my current setup before scaling out.
    Because in my book, less moving parts means simpler architecture and better maintainability. Only scale when you've been maxed out.

    Yeah, I'm doing it that way now. It was probably GlusterFS and NFS slowing things down. Moved to Unison for file replication, everything seems solid for now. The current machine has a R5 3600 (it was upgraded from a small 2 core, 8GB VPS).

  • vyasvyas OG
    edited March 2020

    Deleted. See comment below

    Squats are the new Push-ups

  • WSSWSS OGRetired

    @vyas said:
    acknowledge the sarcasm in the post and take it in stride, makes for a good reading for beginners)

    https://wplift.com/how-to-make-your-wordpress-site-load-really-slow

    Was this stolen from WikiHow?

    My pronouns are like/subscribe.

  • vyasvyas OG
    edited March 2020

    @WSS said:

    @vyas said:
    acknowledge the sarcasm in the post and take it in stride, makes for a good reading for beginners)

    https://wplift.com/how-to-make-your-wordpress-site-load-really-slow

    Was this stolen from WikiHow?

    I would not know- came in a newsletter for WPLift. When I read it I recalled this thread and posted here.

    Squats are the new Push-ups

  • WSSWSS OGRetired

    @vyas said:

    @WSS said:

    @vyas said:
    acknowledge the sarcasm in the post and take it in stride, makes for a good reading for beginners)

    https://wplift.com/how-to-make-your-wordpress-site-load-really-slow

    Was this stolen from WikiHow?

    I would not know- came in a newsletter for WPLift. When I read it I recalled this thread and posted here.

    https://www.wikihow.com/Make-a-Realistic-Farting-Noise

    My pronouns are like/subscribe.

  • SagnikSSagnikS Hosting ProviderOG

    Lol, that's a nice one. Anyhow, I got the client to switch to a better plugin for now, which actually works with the cache, and everything's so much better ^_^

Sign In or Register to comment.