0

I would like to share my situation because maybe helpful to others, and I need some advice.

I administer a VPS with some web servers and high traffic.

The systems specs are x2 Xeon E2620 with 2 cores, 18Gb ram and 800Gb HDD.

The first step when I got full access was check the server configuration.

The system holds:

  • Apache2
  • php-cgi 5.3.3 (prefork)
  • MySQL 5.1
  • Prestashop (1.4 - 1.6)
  • APC

At first sight (later confirmed), the server settings and the system architecture is not optimal.

The server is busy almost all time and web access very slow.

So, I think I have a couple of alternatives to circumvent this situation because the traffic only grows.

  • Optimize the current settings could be only a temporary solution.

It means tuning Apache, preforks, MySQL, uninstalling unneeded software... etc.

OR

  • Change the system architecture thinking in scalability. ( better temp. solution before invest more $$ scaling horizontally)

My idea, and my doubt is what do you recommend for scale.

nginx, php-fpm, varnish, APC OR nginx working together with Apache.

I think first is better because they all still runs in the same machine.

Thanks.

Will
  • 1,127
  • 10
  • 25
ppk
  • 143
  • 2
  • 9

1 Answers1

0

So this is a bit broad of a question, so this will be a broad answer. But, yes, you'll have a much easier time scaling nginx. What I'd recommend for you is to replace Apache and mod_php with nginx and php-fpm. I would also upgrade to PHP 5.6.x and start using the Zend Opcache module that's included with it in place of APC. If you're also using APC for "user caches" and not just opcode caching, you can replace the functionality with the "APCu" module. Varnish could indeed be helpful for increasing performance of serving static assets, but I'd start with the low-hanging fruit.

When you're using php-fpm, your PHP workers can scale independently of your incoming HTTP connections, which can give you an advantage with respect to memory usage. Additionally, the webserver can use threads instead of processes to handle requests, since PHP is running outside of the webserver's memory space.

With the mod_php method you're currently using using, the same process that accepts, waits for, and serves a request is also starting up a PHP interpreter and keeping it in memory until the request has been fully served.

I think you're on the right track; go with your gut, the above is how I would go about it. There will always be more things to tune and optimize, but without knowing more about the specifics of how the system is used and what it's serving, it's hard to go much deeper.

Will
  • 1,127
  • 10
  • 25
  • Oh, have discovered ZendOpcache and APCu modules!. Of course, My motivation is to change the actual behavior using nginx + varnish to serve static content like images, javascript, etc and Apache2, php-fpm, Zend OpCache and APCu to serve dynamic content. All runs in one machine. There always time to scale and explore more complex architectures and other software. @Will – ppk Feb 19 '16 at 14:59
  • Yeah, I understand. nginx can do everything you need though (and maybe add varnish for static assets). There should be no need for Apache2 at all. – Will Feb 19 '16 at 19:42