Hello StackShare Users,
I am Charles. I am currently developing an API for a social media app using Laravel 8. However, there are concurrency concerns from my team members.
With regards to this, what would you advise between Laravel and Phoenix Framework?
Thanks in advance.
Having used both, I would say that both took time to learn (knowing some PHP != knowing Laravel), but I liked the end result a lot better with Phoenix. Also, go with Phoenix if you like sleeping through the night. As you mentioned, Phoenix definitely performs well under heavy load (1000s of concurrent users for $10-20/mo is reasonable). When it comes time to deploy, Phoenix is a little harder to set up, but then it runs well. Forever. With virtually no maintainance (especially if you pick a host that manages the OS for you). PHP is easier to get up and running at first, but it takes more work and a fair bit of experience get it running fast and securely (and then you have to stay on top of the security updates). I have decades of experience hosting PHP sites and I still wouldn't call it easy or comfortable. A third option would be some kind of serverless solution (I use Cloudflare Workers and Firebase Functions). The upside is (near-) limitless scaling, and the downside is (near-) limitless costs. (And, for anything other than Cloudflare Workers, cold starts.)
Could you elaborate on those "concurrency concerns"?
Is it in the sense of 1) many concurrent HTTP requests or 2) asynchronous processing in the code or 3) resource concurrency like race conditions, deadlocks, etc?
1. If it's related to high load, then: what is your expected avg/max request/sec?
2. If it's asynchronicity then does the API do parallel IO operations (eg reach out to other HTTP endpoints, do MULTIPLE DB queries) while serving requests?
3. If it's race conditions/deadlocks then what is the bottleneck resource?
The Laravel eco system is unbeatable, don't stray away from it. There are tools to help out with concurrency. If you're really worried about concurrency, PHP is not the language for you. Look into something along the lines of golang and rust.
I would also interrogate the kind of server that you're using i.e. Apache, Nginx since both do play a big role in how requests are processed. Nginx for example handles all requests in one thread and then processes them asynchronously as NodeJs does while Apache is the ideal tool with multiple threads but it requires good load balancing techniques in production.
Have a look at tools like amphp https://amphp.org/ to kickstart your concurrency implementation.
Don't think about the framework when planning for concurrency, think about what the language has to offer. Concurrency is a concept




