MySQL scale up or scale out?

Go To StackoverFlow.com

0

I have been tasked with investigating reasons why our internal web application is hitting performance problems.

The web application itself is part written in PHP and part written in Perl, and we have a MySQL database which is where I believe the source of performance hit is occurring.

We have about 400 users of the system, of which, most are spread across different timezones, so generally there are only ever a max of 30 users online at any one time. The performance problems have crept up on us, particularly over the past year as the database keeps growing.

The system is running on one single 32-bit debian server - 6GB of RAM, with 8 x 2.4GHz intel CPU. This is probably not hefty enough for the job in-hand. However, even at times where I am the only user online, page loading time can still be slow.

I'm trying to determine whether we need to scale up or scale out. Firstly, I'd like to know is how well our hardware is coping with the demands placed upon it. And secondly, whether it might be worth scaling out and creating some replication slaves to balance the load.

There are a lot of tools available on the internet - probably a bit too many to investigate. Can anyone recommend any tools that can provide some profiling/performance monitoring that may help me on my quest.

Many thanks, ns

2012-04-04 17:04
by nonshatter
Admittedly, I know almost nothing about Debian, but shouldn't you be using a 64-bit OS to be able to utilize over 4 GB or RAM - Branko Dimitrijevic 2012-04-04 18:23
I think it depends whether it is a PAE enabled kernel or not - nnichols 2012-04-04 18:46


4

Your slow-down seems to be related to the data and not to the number of concurrent users.

Properly indexed queries tend to scale logarithmically with the amount of data - i.e. doubling the data increases the query time by some constant C, doubling the data again by the same C, doubling again by the same C etc... Before you know it, you have humongous amounts of data, yet your queries are just a little slower.

If the slow-down wasn't as gradual in your case (i.e. it was linear to the amount of data, or worse), this might be an indication of badly optimized queries. Throwing more iron at the problem will postpone it, but unless you have unlimited budget, you'll have to actually solve the root cause at some point:

  1. Measure the query performance on the actual data to identify slow queries.
  2. Examine the execution plans for possible improvements.
  3. If necessary, learn about indexing, clustering, covering and other performance techniques.
  4. And finally, apply that knowledge onto queries you have identified in steps (1) and (2).

If nothing else helps, think about your data model. Sometimes, a "perfectly" normalized model is not the best performing one, so a little judicial denormalization might be warranted.

2012-04-04 18:20
by Branko Dimitrijevic


2

The easy (lazy) way if you have budget is just to throw some more iron at it.

A better way would be, before deciding where or how to scale, would be to identify the bottlenecks. Is it every page load that is slow? Or just particular pages? If it is just a few pages then invest in a profiler (for PHP both xDebug and the Zend Debugger can do profiling). I would also (if you haven't) invest in a test system that is as similar as possible to the live system to run diagnostics.

You could also look at gathering some stats; either at server level with a program such as sar (from the sysstat package and also at the db level (have you got the slow query log running?).

2012-04-04 17:11
by liquorvicar
Yeah, if it's slow with only one user, scaling isn't the issue. Fixing performance is - ceejayoz 2012-04-04 17:19
Thanks for your input. We have used sar for the last year or two, but it doesn't particularly tell us much about MySQL performance specifically.

I will look into some of your suggestions and get back to you.

Many thanks - nonshatter 2012-04-04 19:57

Ads