LAMP Performance Tuning

by 40 replies
47
We're looking to hire someone to help performance tune a LAMP server running Elgg CMS (PHP/MySQL).

It's a dedicated box and should have good enough hardware but has been running slower than normal lately.

Let me know if you know someone who can help us out

Cheers,
Kane
#programming #elgg #lamp #mysql #performance #php #tuning
  • What type of slow? MySQL queries slower than normal or...More specific? If you want to PM me, please do, I may not check back on this topic.
    • [1] reply
    • Page load times are slower than normal. We'd have some complaints too. Wish I had more specific metrics but don't at the moment.
  • Switch to nginx or at least lighttpd !

    Apache suck !

    Simple suggestion
    • [1] reply
    • Apache doesn't suck. It works for a lot of applications just fine.

      Also, how do you know the OP's problem is due to running Apache and not nginx or lighttpd? There's other things that could be causing his problem besides the http server he's using.
      • [ 1 ] Thanks
  • i know of a good guy to help you.
    he is on elance.com his name is Aaron, his handle on elance is Zebb C , he totally improved speed on our website by optimizing server, even tho most of the problem was all the mysql calls.
    he installed memcache and mysql query caching (those were the main 2)
    • [ 1 ] Thanks
    • [1] reply
    • Awesome, thanks for the advice, I'll contact Aaron

  • Not really enough information. What is the URL of the website?

    website optimization
    Try using the above.
    • [2] replies
    • wasabi - simple suggestion for you: don't make blanket statements about something you obviously don't know anything about.



      Moving the database to a second server and linking them together won't necessarily solve the problem. If MySQL isn't setup nicely it will run into the exact same problem.

      And I'm not sure if splitting it into multiple applications is an option as the OP said he's using some CMS system, chances are they don't know how to separate it out (if it's even possible with that specific platforms).





      You'll need to narrow it down a bit more to get help. I would speculate your problem is with MySQL.

      If the CMS you are using doesn't do any kind of caching by default, then it's really easy to rack up a huge number of mysql queries. Furthermore, if the queries that it runs aren't optimized then you'll run into big performance issues.

      Can you login to mysql and run this command and paste the output here: show status;

      That will output a huge table listing various things about MySQL which I can use to help diagnose your problem.

      Another thing that could be part of the problem is how apache is configured. What is the current min/max server setting? How many clients are enabled?

      How much traffic are you getting every day?
      • [ 2 ] Thanks
      • [2] replies
    • It's SocialAdr.

      Thanks, I'll check out that website optimization service.

  • That's not enough information for anybody here to help you. You haven't even revealed the site that people are experiencing slow load times with. All that people here can do is speculate on a number of factors which may not have anything to do with your problem.

    You might want to start by posting a URL.
  • Good idea. Start with the basics before you pay someone to do a service you may not require.

    There are just too many "what if's" that only you can answer. New files, code changes, and, most important, your logs. Start there and see what is sucking up your resources. There are tons of programs/addons that will give you great stats on your server, but not knowing what you use to track your server's performance...it just makes this question one for someone you trust with server access.

    Just looking at your website, you have lots of stuff going on.
    98 page objects (http requests like this are most likely the cause of "slowness") 91 of which, images.
    • [ 1 ] Thanks
    • [1] reply
    • Thanks for suggestions and ideas so far. A few details: this is a relatively high-volume site with an Alexa around 5k or so. We've done a lot of work on speed/performance already. We use caching, pre-calculation in some areas, etc.

      I think the vexing part of the current performance issues is the lack of any resource-bounding. In other words, if we look at the monitors we have plenty of CPU lying around, plenty of memory available, but the pages are sometimes running slow anyway. That tend to lead me to think that splitting to multiple boxes won't really help, or at least not in a significant way.
      • [1] reply
  • We're in the process of installing Munin too, so we can better monitor the performance and know for sure if changes we make are helping.

    Also, if it helps, this is our server - http://www.servint.net/v_dedicatedservers.php - "Solo Pro 850".
  • Something else that jumped to mind, if you have tables with millions of rows are you frequently optimizing them? That makes a big difference when you get massive tables.

    I have a script I can send that checks all your tables and optimizes them as needed. Works wonders when you run it under cron.
  • That's the average it uses throughout the day. Try logging in via SSH and running the "top" command a few times throughout the day and see how much CPU "mysql" is using.
    • [1] reply
    • Ok, I did this and on average it seems fairly low, around the 3% that WHM "Daily Process Log" shows. I saw it bounce around a bit, the highest being around 12% and the lowest 1%.

  • Hmm...that's strange. What about apache, how many servers are setup?
    • [1] reply
    • AFAIK only one Apache server is setup. Check out the attachment.

      So I've got Munin installed now. My plan is to start doing the things you suggested and monitor it to see how much improvement each change makes. Does that sound ok?

      Cheers,
      Kane

  • Ok I bumped up the MySQL "query_cache_size" from 128M to 512M. Hopefully that helps.

    Also, our OS is CENTOS 5.7 i686. Would we benefit from having a 64-bit OS?
  • khtm, I think changing OS may help, but a bit too late, I would stick with it a while.
    I think Christian is right your problems are db, but normally "top" will show mysql sucking up some memory & cpu.
    can you spare any more memory to the query cache? maybe 1G?
    optimizing a lamp install can get expensive, but it can be worth it.
    The other option is to optimize the queries at the PHP level (which can also be expensive).

    If it were me, my first step would be to get someone to narrow down the exact slowdown, with some performance tools. (Maybe you could pay Christian), then address the issue.
    It may be that you need to move the db to a separate server? or something like that.
    • [1] reply
    • Thanks Johnny, I updated query_cache_size to 1024M.

      Some more info. I ran the mysqltuner.pl script and here's the results:

      Code:
       >>  MySQLTuner 1.2.0 - Major Hayden <major@mhtx.net>
       >>  Bug reports, feature requests, and downloads at http://mysqltuner.com/
       >>  Run with '--help' for additional options and output filtering
      
      -------- General Statistics --------------------------------------------------
      [--] Skipped version check for MySQLTuner script
      [OK] Currently running supported MySQL version 5.0.92-community-log
      [!!] Switch to 64-bit OS - MySQL cannot currently use all of your RAM
      
      -------- Storage Engine Statistics -------------------------------------------
      [--] Status: +Archive -BDB +Federated +InnoDB -ISAM -NDBCluster 
      [--] Data in MyISAM tables: 37G (Tables: 256)
      [--] Data in InnoDB tables: 241M (Tables: 18)
      [--] Data in MEMORY tables: 0B (Tables: 6)
      [!!] Total fragmented tables: 30
      
      -------- Security Recommendations  -------------------------------------------
      [OK] All database users have passwords assigned
      
      -------- Performance Metrics -------------------------------------------------
      [--] Up for: 1d 8h 43m 6s (23M q [203.630 qps], 100K conn, TX: 2B, RX: 3B)
      [--] Reads / Writes: 93% / 7%
      [--] Total buffers: 1.3G global + 20.4M per thread (1000 max threads)
      [!!] Allocating > 2GB RAM on 32-bit systems can cause system instability
      [!!] Maximum possible memory usage: 21.2G (273% of installed RAM)
      [OK] Slow queries: 0% (97/23M)
      [OK] Highest usage of available connections: 4% (49/1000)
      [OK] Key buffer size / total MyISAM indexes: 128.0M/3.9G
      [OK] Key buffer hit rate: 99.9% (828M cached / 579K reads)
      [OK] Query cache efficiency: 42.1% (9M cached / 22M selects)
      [OK] Query cache prunes per day: 0
      [OK] Sorts requiring temporary tables: 0% (0 temp sorts / 283K sorts)
      [OK] Temporary tables created on disk: 3% (6K on disk / 175K total)
      [OK] Thread cache hit rate: 99% (49 created / 100K connections)
      [OK] Table cache hit rate: 39% (412 open / 1K opened)
      [OK] Open file limit used: 5% (456/9K)
      [OK] Table locks acquired immediately: 99% (48M immediate / 48M locks)
      [OK] InnoDB data size / buffer pool: 241.5M/512.0M
      
      -------- Recommendations -----------------------------------------------------
      General recommendations:
          Run OPTIMIZE TABLE to defragment tables for better performance
      Guess I should make those two changes

      Cheers,
      Kane

  • OK, try this:

    In WHM, click on Apache Configuration, then on Global Configuration. Scroll down until you see "Minimum Spare Servers" and "Maximum Spare Servers". What are they set to?
    • [1] reply
    • Min = 5, Max = 10

      Is that normal?

      • [1] reply
  • I'd bet your bottleneck is MySQL related as some others have stated. I'd bet the farm you have a lot of queries that have not been indexed correctly, if at all. I've seen this a thousand times.

    It's quite easy to fix your issues, it simply requires a methodical approach.

    -Monitor slow queries (disable logging queries not using index)
    -Find each of these queries in your application code
    -Run a describe on each query
    -Fix index issues etc.

    You have a 40GB database. Randomly tweaking settings is not the solution to your problems at this point. You have to find and address each bottleneck 1 by 1. I find it's easier to start at the database level and work your way out to the webserver.

    Good luck!
  • The only suggestion I can give you: NGINX ALL THE WAY
    • [ 1 ] Thanks
    • [1] reply
    • Banned
      [DELETED]
    • Interesting, I hadn't even heard of NGINX but I did some searching and their are Elgg implementations that use it with noticeable performance increases....

      hmmmm...gives me something to think about!

  • LAMP is Linux Apache MySQL PHP...

    So no N ginx in there ... LNMP ... sounds bad.

    OK, back to the post...

    I have experience in tweaking Apache with different techniques.

    Check out my blog @ www.cookielessdomain.com
  • Hey Kane,

    do you mean "tuning" = making the pages load faster on the customer's side?

    can't help you with "tuning" a LAMP stack/server - but when we started a page with a huge load of (paid) traffic, I was very concerned about performance and tried a lot of things to get the page load time down (was: 8 secs). What helped me most: Using good caching tools (for WP CMS) and, mos timportant: Host all images ona cdn.

    We're down to <1sec now....

    Cheers,
    Rob Konrad
    • [1] reply
    • Yeah, as well as improve performance with our back-end jobs. Thanks for your suggestions.

  • Banned
    [DELETED]
  • Apache works great for this. It is a highly configurable piece of software. It has a lot of features, but each one comes at a price. Tuning Apache is partially an exercise in proper allocation of resources, and involves stripping down the configuration to only what's needed.
  • One of my hosts recently switched from Apache to Lightspeed Webserver, apparently it is much more efficient and is highly optimized giving much better performance and security.

    All I know from a user stand point, I see no difference in functionality. htaccess and custom php.ini works but now I do not need any reference to php.ini in my htaccess file. My sites load quickly and cpanel works the same as it did before under apache.

    Maybe it is just my host but several new php modules and features were added which make things a little but easier from a webdesign and programming stand point.

    As long as I can do what it is I want to in the way I want to do it then I don't really care what is being used on the backend. Basically I see no downside to the switch my host did from apache to lightspeed. Google it, they have a lot of interesting features that standard apache doesn't.

    - T
  • I'd listen to Christian...

    From the looks of it, the problem seems your database and the queries. I'd hire a database optimizer to take a look at your database and the queries that you're passing to it. It won't matter if you upgrade to nginx if the database is the problem.
  • Just an update:

    We've hired a fella off oDesk to help analyze and configure our server better. And we're in the midst of moving hosts to WiredTree and from a single dedicted box to a more distributed configuration.

    Thanks everyone for the suggestions so far! I'll keep this thread updated as we move along.

Next Topics on Trending Feed

  • 47

    We're looking to hire someone to help performance tune a LAMP server running Elgg CMS (PHP/MySQL). It's a dedicated box and should have good enough hardware but has been running slower than normal lately.