How to set up a Laravel application that can handle a lot of visitors [+ useful tools]

Published 03 June 2020 21:47 (3-minute read)

This is a topic that's a bit difficult to explain and what is "a lot of visitors". In this post I tried to explain how we (in the projects I've been working on) setup our applications to handle millions of visitors every month.

To begin with, this is not just one application that's handling all those millions of visitors. In total it's more than 2 million unique visitors.

All our applications follow a standard set of tools we use to develop. Cloudflare, Laravel, Laravel Forge, Laravel Deployer, MySQL, Redis, G Suite, Pusher & Tailwind.

Note: this article will be updated/extended in the coming weeks...

Cloudflare

Why do we use Cloudflare, what are the benefits of using Cloudflare, and does it work?

The simple answer is, yes, we need Cloudflare. Without Cloudflare we had to increase our servers to handle all those static files our servers need to handle. Nowadays Cloudflare handles the distribution of all those static files and our servers only need to handling the back-end tasks that cannot be cached by Cloudflare.

Cloudflare site analytics


When we take a look at the Cloudflare statistics we see a cache percentage of more than 74% (yes, I know, it could be more). Imagine, we simply saved our server to handle around 74% off the static assets that can be used to handle other traffic. In the end, this saves us money. Why wouldn't you use Cloudflare if it could save you ?? For some projects, it's not necessary to enable Cloudflare to cache some files, but for large projects, that have more than a million visitors this could lead to some big money ?.

The following screenshot is a screenshot of the new Cloudflare Analytics dashboard that show you an overview much more in details for specific locations that are accessing the application. We served for this simple applications around 5.82 million requests with the most visitors coming from The Netherlands and The United States. Imagine all those assets that need to cross the ocean (when you only have a single server based in Amsterdam to handle those requests) to the other side of the world, it takes same time. But now, only the first time a visitor requests the image have to wait a bit, after that Cloudflare will handle the asset and serves it from the nearest datacenter. In total Cloudflare serves those assets from around 200+ locations world wide (!).

Interested in the current datacenter locations from Cloudflare? Take a look at their network on cloudflare.com/network.

Cloudflare analytics statistics

Laravel

Coming soon...

Laravel Forge

Coming soon...

Laravel Deployer

Coming soon...

G Suite

Coming soon...

Tailwind

Coming soon...

Pusher

Coming soon...

Robin Dirksen

Follow me on Twitter, there I post web-related content, tips/tricks, and other interesting things.

On my blog, you can find articles that I've found useful or wanted to share with anyone else.

If you want to know more about this article or just want to talk to me, don't hesitate to reach out.