Back in March, I spent some time helping Eric optimize Laravel News. We went through the site's most requested pages and worked on caching them at the edge with Cloudflare. The goal was to improve response times while reducing the amount of traffic reaching the application.
Eric and I walked through some of the changes together in this video. I also wrote about some of the immediate wins, including blocking invalid requests to your Laravel application. And I cover all of the practices in Fast Laravel.
Around the same time, Laravel News migrated to Laravel Cloud. The original goal was always to see how much we could save on the infrastructure bill. But rather than immediately start changing resources, we decided to let things run for a while and see how the application settled.
A few months later, we caught up at Laracon. Eric shared his Laravel Cloud bill with me, and I immediately had suggestions.
A solid foundation
At this point, Laravel News was already benefiting from the Cloudflare work we had done.
While the site receives a considerable amount of traffic, a majority of its popular pages were cached. That means only a fraction of those requests actually make it through to Laravel Cloud.
We also made sure the application was doing less work when requests did reach Laravel. Expensive operations, such as rotating sponsors and recent articles, were cached by the application.
Between edge caching and application caching, the workload was considerably smaller than the infrastructure resources suggested.
This is an important foundation. Even though the site received a lot of traffic, it didn't need the compute to handle every request. And, when it did handle a request, it fell back on the application's cache.
Right-sizing the infrastructure
The first thing we noticed was that the database and compute resources were larger than necessary. Given the foundation, neither resource needed to be as large as it was.
We were able to reduce both to the smallest Flex resources available.
But the biggest opportunity was actually the Valkey cache. At 5 GB, it was one of the largest expenses on the bill. That's a lot of cache! And while it was being used, I wanted to understand why so much was needed.
With a few targeted prompts, AI found several large cached values. One example was the recent articles. The application was caching entire Eloquent collections, even though the views only needed three attributes: the title, slug, and thumbnail.
That meant we were storing not only the entire Eloquent object structure, but also large fields like the article content. None of that was needed. Instead, we changed the cached values to simple tuples containing just those three attributes.
After optimizing the cached values, we were able to reduce the Valkey resource from 5 GB to just 512 MB. That's nearly a 90% reduction in capacity. All with minimal code changes.
Laravel News now runs on the smallest Flex resources for all three services: compute, database, and cache.
Nearly half the bill
All in, these changes cut Eric's Laravel Cloud bill from $129 to $72 per month.
That's a savings of $57 every month. That's $684 every year. And these were really just the obvious savings.
There are still opportunities to reduce costs further. A few minor refactors could reduce resource requirements even more, potentially allowing Eric to move to a lower Laravel Cloud plan.
None of these changes required a major rewrite. We simply took another look at what the application was actually using and sized the infrastructure accordingly.
Finding savings in your Laravel Cloud bill
After working through this with Eric, I started applying the same practices to my own environments on Laravel Cloud. I offered to do the same for a few other members of the Laravel community.
Eventually, I decided to roll this into a new service: Thrift.
Thrift helps you find savings hiding in your Laravel Cloud bill. You upload your bill and provide a read-only API key. It analyzes your resources and identifies opportunities to reduce costs.
But I didn't want to stop at identifying oversized resources. There are often deeper savings hiding in the application itself. So Thrift also provides targeted prompts you can hand to your AI for potential optimizations.
My benchmark is 20% savings. Again, that adds up over a year. Some customers have seen savings as high as 60%. At that level, Thrift pays for itself in the first month. And unlike a one-time optimization, the savings continue month after month.
I think there's a lot of opportunity here. Laravel Cloud makes it incredibly easy to scale resources and get an application running. But that convenience also makes it easy to overprovision.
Sometimes the best optimization isn't adding more. It's figuring out how to use less.