Search code examples
phpmysqllamp

Scaling LAMP


I have a client with a LAMP website serving mostly video. He is currently on one server with all components. He is having some scaling problems. What are some of the techniques that can be used to help.

I used separating out the DB to another server with a GB Ethernet between it and the webserver. Maybe adding more web servers with some load balancing and additional MySQL servers with replication?

Would like some medium, large, super large examples on how to scale if possible.

The video is actually coming as jpg images. Similiar to this website:

http://www.webcams.travel/webcam/1170170095

And to add some details. I figure the max visitors per hour would be 1000, and I think would be lucky to have that. Maybe closer to 1000 a day.


Solution

  • The advice about CloudFront and MemCache etc. is all good, assuming those address the root of your performance issues.

    On the database side: Profile, profile, profile. Moving the DB to a separate server was (probably) a good step, but if you haven't profiled the queries being run on this DB instance, you don't know what you need to improve.

    Start by doing an EXPLAIN on the most common queries, and check whether you're doing unnecessary sequential scans on large or growing tables. Index as necessary.

    Are any of the queries passing back columns that aren't used?

    Are you, as other commenters were worried, serving your graphic/video content from the database? Files should be kept in the filesystem, and served from there.

    Are all your tables MyISAM? Frequently-updated tables may show performance improvement by moving them to InnoDB, where they can benefit from row-level locking (as opposed to MyISAM's table-level locking).

    These are just simple, general recommendations - without more specifics on exactly what is slow, it's tough to offer anything deeper.