Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The ideal multi-server LAMP environment

There's alot of information out there on setting up LAMP stacks on a single box, or perhaps moving MySQL onto it's own box, but growing beyond that doesn't seem to be very well documented.

My current web environment is having capacity issues, and so I'm looking for best-practices regarding configuration tuning, determining bottlenecks, security, etc.

I presently host around 400 sites, with a fair need for redundany and security, and so I've grown beyond the single-box solution - but am not at the level of a full ISP or dedicated web-hosting company.

Can anyone point me in the direction of some good expertise on setting up a great apache web-farm with a view to security and future expansion?

My web environment consists of 2 redundant MySQL servers, 2 redundant web-content servers, 2 load balancing front-end apache servers that mount the content via nfs and share apache config and sessions directories between them, and a single "developer's" server which also mounts the web-content via nfs, and contains all the developer accounts.

I'm pretty happy with alot of this setup, but it seems to be choking on the load prematurely.

Thanks!!

--UPDATE--

Turns out the "choking on the load" is related to mod_log_sql, which I use to send my apache logs to a mysql database. By re-configuring the webservers to write their sql statements to a disk file, and then creating a separate process to submit those to the database it allows the webservers to free up their threads much quicker, and handle a much greater load.

like image 923
Brent Avatar asked Sep 20 '08 15:09

Brent


People also ask

What is LAMP server used for?

LAMP is an open source Web development platform that uses Linux as the operating system, Apache as the Web server, MySQL as the relational database management system and PHP as the object-oriented scripting language. (Sometimes Perl or Python is used instead of PHP.)

What is the LAMP stack what are some of its common variants?

Linux, Apache, MySQL and PHP are the cornerstone of a free, non-proprietary LAMP stack. There are several variants of the four stack model as well. These variants use alternative software replacing one or more of the traditional components.


1 Answers

You need to be able to identify bottlenecks and test improvements.

To identify bottlenecks, you need to use your system's reporting tools. Some examples:

  • MySQL has a slow query log.
  • Linux provides stats like load average, iostat, vmstat, netstat, etc.
  • Apache has the access log and the server-status page.
  • Programming languages have profilers, like Pear Benchmark.

Use these tools to identifyy the slowest/biggest offenders and concentrate on them. Try an improvement and measure to see if it actually improves performance.

This becomes a never ending loop for two reasons: there's always something in a complex system that can be faster and as your system grows, different functions will start slowing down.

Based on the description of your system, my first hunch would be disk io and network io on the NFS servers, then I'd look at MySQL query times. I'd also check the performance of the shared sessions.

like image 141
Gary Richardson Avatar answered Oct 04 '22 01:10

Gary Richardson