The ideal multi-server LAMP environment
Asked Answered
V

3

7

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.

Vada answered 20/9, 2008 at 15:13 Comment(1)
I would change the title for something like "The ideal middle level LAMP environment"Beeson
B
3

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.

Brasher answered 20/9, 2008 at 17:47 Comment(0)
C
2

The schoolbook way of doing it would be to identify the bottlenecks with real empirical data.

Is it the database, apache, network, cpu, memory,io? Do you need more ram, sharding(+), is the DiskIO, the NFS network load, cpu for doing full table scans?

When you find out where the problem is you might run into the problem that its not enough to scale the infrastructure, because of the way the code works, and you end up with the need to either just create more instances of you current setup or make the code different.

Coopt answered 20/9, 2008 at 15:49 Comment(1)
scribd.com/doc/272292/…Coopt
I
0

I would also recommend as a first step in terms of scalability, off-load your content to a CDN like Edgecast. Use your current two content servers as additional web servers.

Introrse answered 2/6, 2010 at 19:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.