5

I'm running a WEB application (PHP + MariaDB) for my company, developing on my laptop and running the production version on a dedicated server.

Recently, I've started to measure performance and noticed that my laptop performs better than the server. For instance, one of the pages is generated in ~50ms on my laptop vs. ~130ms on the server. This time is measured in the PHP code using microtime(), thus network requests delays to the server are ignored.

The thing is, the server should perform better than my laptop on every single point. 130ms is OK for this application, hence the reason I've never noticed this fact. But if possible I'd like to understand what causes this.

I guess the next step would be to measure time at different points of the code, but the difference is so important (> x2.5) that I can't help thinking I'm missing something.

Here are some details.

CPU

  • Laptop: Intel(R) Core(TM) i5-5200U CPU @ 2.20GHz
  • Server: Intel(R) Xeon(R) CPU E3-1270 v6 @ 3.80GHz

RAM

  • Laptop: 16 GB DDR3 @ 1600MHz
  • Server: 32 GB DDR4 @ 2400MHz

OS

Both are running Debian 9, thus they're running the same version of Apache2, PHP, MariaDB... and should be configured more or less in the same way.

MariaDB

On the server, it's configured to use 24GB of RAM for InnoDB pool size split into 12 instances (all tables are using InnoDB). Currently, it's using only 4.5GB of RAM so disk accesses should not be an issue.

What else?

  • Swap usage is null
  • CPU is idle most of the time
  • In particular, the measurements were made at moments where no one else was using the application
  • The server is running other services (e.g., git, other WEB applications) that should not have such impact on performances, especially given the low CPU usage
  • What about the network latency? On your local notebook you wouldn't have any ... – bjoster Feb 21 '18 at 13:26
  • 1
    Does your laptop have an SSD and the server traditional rotational disks? – Janne Pikkarainen Feb 21 '18 at 13:32
  • @bjoster As I said, the time is measured in the PHP script and Apache2 is running on the same server as MySQL, so I'm not sure were the network latency could be. – François Feb 21 '18 at 14:04
  • @JannePikkarainen Both are using traditional hard drives. Moreover on the server MySQL only uses 4GB of RAM for InnoDB cache while it's allowed to use up to 24 GB, so to me the tables should be cached and no I/O should occur. – François Feb 21 '18 at 14:06
  • 2
    Ideally you have more specific timing data down to the function calls. Try some profilers, maybe xhprof or xdebug. Or host wide profiling, like perf record. – John Mahowald Feb 21 '18 at 14:21

protected by Sven Mar 26 at 12:05

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Browse other questions tagged or ask your own question.