Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Laravel 5 handle 1000 concurrent users without lagging badly?

I wanted to know that if 1000 users are concurrently using a website built with laravel 5 and also querying database regularly then how does laravel 5 perform ? I know it would be slow but will it be highly slow that it would be unbearable ? Note that i am also going to use ajax a lot.

And lets assume i am using digital ocean cloud service with following configurations

2GB memory
2 vCPU
40GB SSD

I don't expect completely real figures as it is impossible to do so but at least provide some details whether i should go with laravel with some considerable performance.

Please also provide some some tools through which i can check the speed of my laravel 5 application as well as how it will perform when there is actual load as well as other tools through which i can test speed and performance.

And it would be great if someone has real experience of using laravel especially Laravel 5.

And what about Lumen does that really make application faster than laravel and how much ?

like image 265
Raj Avatar asked Nov 29 '17 05:11

Raj


1 Answers

In short, yes. At least newer versions of Laravel are capable (Laravel 7.*).
That being said, this is really a three part conundrum.


1. Laravel (Php)

  • High Concurrency Architecture And Laravel Performance Tuning

Honestly, I wouldn't be able to provide half the details as this amazing article provides. He's got everything in there from the definition of concurrency all the way to pre-optimization times vs. after-optimization times.



2. Reading, Writing, & Partitioning Persisted Data (Databases)

  • MySQL vs. MongoDB

I'd be curious if the real concern is Php's Laravel, or more of a database read/write speed timing bottleneck. Non relational databases are an incredible technology, that benefit big data much more than traditional relational databases.

  • Non-relational Databases (Mongo) have a much faster read speed than MySql (Something like 60% faster if I'm remembering correctly)
  • Non-relational Databases (Mongo) do have a slower write speed, but this usually is not an inhibitor to the user experience
  • Unlike Relational Databases (MySQL), Mongo DB can truly be partitioned, spread out across multiple servers.
  • Mongo DB has collections of documents, collections are pretty synonymous to tables and documents are pretty synonymous to rows.
  • The difference being, MongoDB has a very JSON like feel to it. (Collections of documents, where each document looks like a JSON object).
  • The huge difference, and benefit, is that each document - AKA row - does not have have the same keys. When using mongo DB on a fortune 500 project, my mentor and lead at the time, Logan, had a phenomenal quote.

"Mongo Don't Care"

This means that you can shape the data how you're wanting to retrieve it, so not only is your read speed faster, you're usually not being slowed by having to retrieve data from multiple tables.

Here's a package, personally tested and loved, to set up MongoDB within Laravel

  • Jessengers ~ MongoDB In Laravel

If you are concerned about immense amounts of users and transferring data, MongoDB may be what you're looking for. With that, let's move on to the 3rd, and most important point.


3. Serverless Architecture (Aka Horizontal scaling)


Aws, Google Cloud, Microsoft Azure, etc... I'm sure you've hear of The Cloud.

This, ultimately, is what you're looking for if you're having concurrency issues and want to stay within the realm of Laravel.

It's a whole new world of incredible tools one can hammer away at -- they'er awesome. It's also a whole new, quite large, world of tools and thought to learn.

First, let's dive into a few serverless concepts.

  • Infrastructure as Code Terraform

    "Use Infrastructure as Code to provision and manage any cloud, infrastructure, or service"

  • Horizontal Scaling Example via The Cloud

    "Create a Laravel application. It's a single application, monolithic. Then you dive Cloud. You discover Terraform. Ahaha, first you use terraform to define how many instances of your app will run at once. You decide you want 8 instances of your application. Next, you of course define a Load Balancer. The Load Balancer simply balances the traffic load between your 8 application instances. Each application is connected to the same database, ultimately sharing the same data source. You're simply spreading out the traffic across multiples instances of the same application."

  • We can of course top that, very simplified answer of cloud, and dive into lambdas, the what Not to do's of serverless, setting up your internal virtual cloud network...

Or...we can thank the Laravel team in advance for simplifying Serverless Architecture

  • Yep, Laravel Simplified Serverless (Shout out Laravel team)

    • Serverless Via Laravel Vapor

Laravel Vapor Opening Paragraph

"Laravel Vapor is an auto-scaling, serverless deployment platform for Laravel, powered by AWS Lambda. Manage your Laravel infrastructure on Vapor and fall in love with the scalability and simplicity of serverless."


Coming to a close, let's summarize.

Oringal Concern

Ability to handle a certain amount of traffic in a set amount of time

Potential Bottlenecks with potential solutions

Laravel & Php

Database & Persisting/Retrieving Data Efficiently

  • Jessengers ~ MongoDB In Laravel

Serverless Architecture For Horizontal Scaling

  • Serverless Via Laravel Vapor
like image 138
Clean Code Studio Avatar answered Sep 28 '22 15:09

Clean Code Studio