zhiyong's avatar

How to optimize performance of Lumen App?

Hi,

I recently re-wrote an app that was written in bare bone PHP with Lumen(Eloquent enabled). The app was mostly about INSERT posted data into mysql database. Although I expected some performance toll, but the benchmark results still surprised me. On the same machine with same setup of (ubuntu/php/apache2), when tested via Jmeter(5000 request with 1 ~ 100 concurrent threads), the average sample time increased from 35 ~ 1400ms to 250 ~ 11000ms depending on number of concurrent threads, and throughput the same machine can handle dropped from processing 1000 request/second to ~80 request/second.

Can someone provide some high level guidance on how to optimize? I do like working with Lumen and do NOT want to a month worth of work to fly out of window :)

Thanks in advance.

0 likes
5 replies
proyb6's avatar

Looking at overall optimization or database? I think were there any debug enabled?

zhiyong's avatar

@proyb6 APP_DEBUG was set to false, and all exception bug etc haven worked out. The logic works just fine. Just the performance. Also I don't think DB is the issue. All mysql settings were the same. I just changed the DocumentRoot from one folder to another.

proyb6's avatar

If you want to tweak near native performance, compile any languages to C or LLVM is the only way to go and it's an achievement than nginx keep access files when your code don't always changes at all like what Facebook did without upgrade your server instance.

zhiyong's avatar

For anyone who might be interested. The problem turned out to be an uncaught error that only shows up when lumen-app was stress tested by jmeter. This uncaught error greatly increased latency and then decreased throughput. After fixing the error, the performance is more inline of my expectation, a decrease of ~15% on throughput.

Please or to participate in this conversation.