226 points · by ericbarnes · 11y ago · 110 comments
Laravel is one of my favorite frameworks, especially since 5.0 given its noble attempt to adhere to contract-first/interfaced development and many best practices that in some ways prevent the "worst" kinds of code from being written. It's not static typing, but it's a step in the right direction.
This seems like it's heavily optimized over the Laravel base, and if high speed and concurrency is important enough that you'd choose Lumen, then it seems like you'd still be stopping halfway in a bit of a "if you have a hammer everything seems like a nail" situation. Unless I'm missing something Lumen still requires resources to be bootstrapped on request, and ultimately that (in the context of a framework) will lead to memory leaks in a loosely-typed language; no way around that.
Also because disk writes will quickly become the bottleneck before your network capacity does, the two most relevant performance enhancements are to use a non-blocking event-loop (with expensive writes deferred to a tick cycle) and to completely avoid any unnecessary per-request bootstrapping--best done with raw PHP and ideally kept simple. This, combined with an optimized TCP configuration and split-per-process nginx LB at the head will give me r/s 10-50x the purported benchmarks. As much as 1000x when introducing intelligent edge-caching rules.
Is there a situation where this would be the right tool for the job/more ideal than the base framework but not worthy of a "roll-your-own" solution?
Either way +1 for Taylor Otwell as a developer and the general quality of his code/releases--Laravel is an ambitious project, and as a developer quite enjoyable to work with!
But if your service is getting that popular, memory leaks are going to be a problem, maybe moving to HipHop (or whatever it's called now) or Node or something is a better idea.
Sounds like you're having fun!
I think you hit the nail on the head again too, since frameworks as a philosophy don't intrinsically value shared-nothing (SN) principles which is the other 'dimension' to scalable concurrency--from a devops perspective, anyway.
And while there's never complete isolation, minimizing that interdependence makes your builds that much more environment-agnostic, and easy to provision dynamically.
Honestly what I'd love to see is a kernel-up PHP environment/container that doesn't focus on runtime in isolation, but the entire TCP stack from syscntl to the webserver (h2o?) and maybe even with some experimental support to extract frequent commands to compiled modules with C headers.
But by that point you'd probably just be using Go or Haskell because that's what compiled, statically-typed languages are for ;)
There is a niche I think for faster than laravel but not incredibly optimised, its another tool not the tool.
At that point you've hit on the essential purpose/elegance of static types and a compiler :)
Can you expand upon that or provide a link with more info? Why would it lead to memory leaks?
Personally, I was a huge fan of Zend Framework + Doctrine, but these frameworks are all mature and great to use.... almost as good as Rails (lol, OK, OK, don't mention Ruby within earshot of PHP fans ;)
[edit] down voted for my opinion! Argh my tiny karma is depleted -- damn you ruby, damn you to hell!
But developing a drupal site is painful. Clearing the cache every few minutes takes forever.
Incidentally, Round 10 is arriving soon.
[1] https://github.com/TechEmpower/FrameworkBenchmarks/issues/15...
What does it mean for a language to have memory leaks? Are you talking about a problem specific to the PHP runtime or common PHP idioms that lead to leaky code? A specific example would be helpful as I've never known PHP to be particularly vulnerable to memory-leak bugs (at least not any more than any of the other popular imperative scripting languages).
Also, what's the substance behind the "etc" in your comment? I'm not really sure what naturally follows in the sequence of "memory-leaks and so on...."
Your comment seems to simply cast doubt without much substance.
It was a big deal when transitioning to the FPM runtime. That's why persistent PHP runtimes like FPM still have the option to completely reinitialize itself after a set number of pageviews. It's a bit like fixing leaks by rebooting, but it's fast enough not to be noticeable.
I'm not embroiled in the PHP-world, so I don't know how many alternate PHP runtimes exist, but I presume that the default PHP runtime itself was being referenced. Seeing as for a long time there was a single runtime paired with the language (I'm 99% sure that PHP4 didn't have alternate runtimes), I think that equating bugs in the runtime with bugs in the language is something that happens even if technically they are separate things.
> Your comment seems to simply cast doubt without much substance.
And your comment seems needlessly defensive. I made a comment about general sentiment that I've gotten from people that have actual working knowledge of large-scale PHP deployments. I'm sorry that in the middle of the conversation I didn't start immediately interrogating these people asking why they haven't filed bug reports if there are memory leaks.
Also, is it devoid of substance if I'm basically stating that I've talked to people "in the trenches" (and presumably know what they are talking about) who don't have the opinion that PHP is some beautiful, but misunderstood language that gets a bad rap?
> Also, what's the substance behind the "etc" in your comment? I'm not really sure what naturally follows in the sequence of "memory-leaks and so on...."
Maybe I should have phrased that as "(e.g. memory leaks)" to show that memory leaks weren't the only complaint, but my memory fails me on what the other complaints were.
In some ways they've introduced some powerful features bringing it on par with other languages, but the reality is that performance varies wildly in the real world because opcaches are finicky dependent on the data/request type/frequency and automated GC/circular-reference optimization is far from perfect.
Between HHVM (to effectively make memory growth linear vs logarithmic when approaching higher request concurrency) and sensible opcache tweaks you can make that runtime a bit less stochastic at scale, however if you don't know what you're doing PHP makes it so easy to go in the complete opposite direction without any indications you're running toward a cliff...
I've used PHP a few times in the past for some long-running, complex cron jobs, and I never had memory leaks. I've also never noticed it for short-running HTTP responses, and some of those have been really awful and messy because I'm more of a PHP doctor than someone who starts projects with it.
Anyway, everyone is going to benefit from HHVM. If Facebook uses it in production, you can be sure that it won't have any common memory leaks for long.
IIRC arrays are always passed by reference and only duplicated if you modify the data inside the called function (if not passed with '&' of course) ?
For now, Silex is still my favorite, as it has the temporary bonus of having more providers available to integrate 3rd party libraries. Sure, I can drop-in whatever library I like, but having someone do the setup (configuring Twig alone can be a burden if you want to get it right) just makes it easier for me ;)
Also you have to be careful with dependencies version or you're quickly in Composer hell (because Symfony moves forward so fast).
Always wanted to compare it with Slim but didn't take the time.
I'm glad its not just me. The documentation gave me problems. I started wondering why I didn't just use symfony in the first place.
Am I doing something wrong or why does it call itself a "micro-framework". A newly created Slim project contains 7417 lines of code.
- BulletPHP: 3946 lines of PHP code
- Slim: 7329 lines of PHP code
- limonade: 3669 lines of PHP code
- Lumen: 95'220 lines of PHP code
You can't call it a micro framework if it's more than ten times bigger than all the other ones.
The term "mirco" refers to the amount of functionality the framework exposes. Often a micro framework is just a router decorated with some other useful stuff. Who cares about lines code, especially when you count "all" dependencies in vendor.
Has the experience remained the same? PHP was incredibly simple to deploy.
Yes and no. The PHP language and run-time continue to value backwards compatibility and, ultimately, a PHP application is still just a collection of PHP files sitting on a web server somewhere. If you want to work like it's 2006 you can.
However -- Modern PHP (Laravel included) bring a few winkles to the table and most deployments will have extra complications for folks expecting to just "FTP a file" (also, I hope you meant SFTP a file (-:)
For example, Laravel (similar to rails) has migrations for creating and updating your database schema. You don't need to use migrations, but if you do your deployment becomes a bit more complicated.
Also -- although PHP namespaces have come a long way, they're still not up-to-par with (or, in PHP group-speak "have different goals than") ruby or python's module system. The Composer packaging system has stepped in to fill this gap, but this means a modern PHP deployment needs to
1. Generate composer autoload cache files 2. Fetch, download and install any updated composer packages (i.e. third party libraries)
Again, there's nothing stopping you from working locally and SFTPing or rsyncing all your local files (composer packages/autoload files included) to the server, but most teams develop a more formal deployment process than that.
How you host your PHP application is going to effect how you deploy. There's still many, many PHP hosting companies offering `mod_php` based hosting, but there's also a large number of projects who use a Fast-CGI/FPM approach (either with Apache or nginx). The difference in process models brings a different in the unix permissions model, and that often means there's extra steps needed to ensure file based cache system can write to their storage engines.
And speaking of caching, 20% of any "serious" PHP developer's time is spent sorting out the various framework level caching systems, as well as PHP based opt-code caching. I mention this here mainly to point out that some sort of cache refresh and/or warming is common in signifigant/long-standing PHP systems.
Deployment's still easier in PHP than in other frameworks, but if you're expect a wild west "just edit files on the server and you're good to go", expect push-back from your modern, professional, PHP developers :)
> They really aren't similar at all. Forge manages sub-domains, Nginx, Cron jobs, SSL certificates, queue daemons, recipes, etc. Envoyer does none of those things. Envoyer is solely focused on deploying PHP applications to multiple servers with zero downtime.
Slim 3 will also be PSR-7 compliant, I don't see anything about that anywhere in these Lumen docs.
Thanks!
My understanding is that the majority of the advertised speed increase has to do with lazy initialization of the request/response stuff and the need to expressly ask for things like session support.
e: Here's an explanation from reddit, http://www.reddit.com/r/PHP/comments/32kajb/lumen_php_microf...
Laravel's strength is that it is batteries included but for some stuff this can be a weakness, API's where that 30-40ms load time matters for example.
I've spent a couple of years working with and on laravel projects and mostly I like it a great deal but it is a sledgehammer when sometimes you need a ballpein.
I think many frameworks allow you to include the "basic" subset of the framework, without running all the usual Inversion of Control bootstrapping.
Hordes of hipster RoR developers making the same mistakes all over again because they refuse to learn from mistakes already made by others. Turning project after project into an unmanageable mess with a marginal life expectancy because they believe their superior elegant language and one-size-fits-all opinionated framework means they don't have to think about architecture and design.
In all my years I've never seen a developer movement piss away its initial success so rapidly as the Rails community.
I must be misunderstanding your point, because the way I read what you wrote, you are insinuating that incorporating good ideas already implemented in a different incompatible technology stack is worthless.
E.g. making a good text editor for windows is worthless because vim/emacs exists, or making a python library for parsing HTML is worthless because there is already a perl one?