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
François
  • 51
  • 1
  • 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
  • What about database size? If you prod database is larger some inefficient queries may take longer to execute. – rvs Mar 26 '19 at 09:01
  • make sure you are using latest lamp version, maybe an outdated program is causing it to perform poorer moreover you could try some other servers like xampp or wa – stephen4312 Mar 26 '19 at 08:50
  • I was wondering could it be the OS prioritizing tasks? Try bumping the nice value of the processes to see if this helps. Can you give us top and a ps of the system? – Mark Scheck Mar 26 '19 at 09:52
  • Do a test with a static page, the time to serve it, as even if you tell there is no IO issue, I see only a IO problem that could cause that. Testing with a static file would rule out IO generated by the mariadb to generate the page – yagmoth555 Mar 26 '19 at 12:21
  • Does your request involve a DB operation and returns some data? If yes you can profile the underlying query on both systems and compare if the difference can be localized to PHP or MariaDB – Dextro67 Aug 12 '19 at 02:04

0 Answers0