0

I'm going to make an API that will have many requests (around 5000 each minute minimum, but could possibly be a lot more). I'm wondering what framework is better for that: Laravel 5.2 or Lumen?

Lumen is a micro framework and especially made for API's but since Laravel 5.2 it's possible to change the middleware. So for my api I could only bind the middleware I need, so no authentication and so on.

That's a big difference with earlier versions of Laravel where the full framework was loaded. So is it since 5.2 still recommended to use Lumen or are the differences in performance very, very small?

Jordy
  • 4,719
  • 11
  • 47
  • 81
  • Don't think so, because this is specifically about the performance after disabling Laravels middleware for an API. Other questions are about the frameworks in general. – Jordy Jul 23 '16 at 08:09

2 Answers2

1

There are some benchmarks out there for PHP frameworks. It's really hard to perform and read benchmarks in a good way, but they should still be able to hint about the difference between them. This seems like a good source: https://github.com/kenjis/php-framework-benchmark. That puts Lumen at 412.36 requests per second, and Laravel at 91.59 requests per second. If your API will have a lot of requests you should probably go with Lumen (or some even faster framework).

If you can you should also use PHP7 since the performance gains are huge compared to PHP5. You can decrease memory load an response times significantly, take a look at this benchmark for Symfony for example.

Disabling middleware for increasing performance is not a problem. There are different ways to register middleware in Laravel. Removing all middleware that comes by default in both the HTTP kernel and on routes is a small task. However there are a lot more to performance than the middleware. Laravel will bootstrap many components that you do not need, this is the reason why Lumen was created in the first place. I do not have a benchmark on how the middleware affects performance specifically, but I would assume it's not the main performance degrader.

Niklas Modess
  • 2,521
  • 1
  • 20
  • 34
  • Thank you. But my question is specifically about the way that Laravel 5.2 can disable middleware for an API. Is there still a huge performance issue after that? – Jordy Jul 23 '16 at 08:08
0

The performance with Lumen will be way faster. Unless you are required to do some really complex operations that only Laravel / Laravel packages will handle, then just go with Lumen.

Also, if you're not going to make use of many features of Lumen or Laravel to a particular endpoint that's going to receive a lot of requests, just point that route to another PHP file in Nginx as there's no point in loading all of Laravel or Lumen's components if there is no need.

Good luck!

  • Thank you. But my question is specifically about the way that Laravel 5.2 can disable middleware for an API. Is there still a huge performance issue after that? – Jordy Jul 23 '16 at 08:08