PHP Performance Trivia
Nikita Popov discusses some low level performance optimizations in PHP.
Posts tagged with performance
Nikita Popov discusses some low level performance optimizations in PHP.
A while ago, I created an easy to use framework agnostic PHP package to read and write CSV and Excel files called spatie/simple-excel. Behind the scenes, generators are used to ensure low memory usage, even when working with large files. Today I added a method that allows you to stream CSV files to the browser. In this small blog post, I'd like to demonstrate how you can use it.
Join 9,500+ smart developers
Get my monthly newsletter with what I learn from running Spatie, building Oh Dear, and maintaining 300+ open source packages. Practical takes on Laravel, PHP, and AI that you can actually use.
No spam. Unsubscribe anytime. You can also follow me on X.
"Always fresh, useful tips and articles. Carefully selected community content. My favorite newsletter, which I look forward to every time."
My buddy Mattias recently improved the performance of the Oh Dear uptime checker servers by disabling the HTTP sessions.
If you run a Laravel application purely as a headless API, you can benefit from disabling the HTTP sessions. We use this setup for our Oh Dear monitoring service, where the remote servers that check for uptime are all headless Laravel setups.
Read more [ma.ttias.be]
My colleague Brent solved a performance by creating a custom relation
One last solution that came to mind was to load all people, all contracts, and map them together manually. In the end that's exactly what I ended up doing, though I did it in the cleanest possible way: using custom relations.
Read more [stitcher.io]
? Did you know you can add query-constraints when eager loading relationships in Laravel?
— Stefan Zweifel (@_stefanzweifel) November 12, 2019
Perfect opportunity to improve query performance when your relationships return thousands of models.
↳ Full example: https://t.co/RsezzpkWoC pic.twitter.com/nwjC7U8Oqa
Read more [twitter.com]
On the Tideways blog, Benjamin Eberlei explains PHPs garbage collection internals.
It's helpful to have a broad understanding of how garbage collection works in PHP, along with how you can interact with it so that you can create high performing applications.
Read more [tideways.com]
Adam Wathan explain how can avoid re-rendering the entire UI everytime you click a link in Next.js
Next.js is such a wonderfully productive development experience and produces such incredibly fast websites that I just refused to believe it had to be this way. So I spent a few weeks researching, asking questions, and experimenting, and came up with these four patterns for persistent layouts in Next.js applications.
Read more [adamwathan.me]
Mathias Hansen shares how API response time data is used at Geocodio and how to work with this kind of data in MySQL.
The API is the backbone of our business, so over the years we have continously worked to improve and ensure consistent performance. We look at many parameters such as uptime and error rates, but one of the key metrics is API response time. This is how we use this data.
Read more [www.codemonkey.io]
Sebastian De Deyne explains how the live updating on Oh Dear status pages works.
We were originally going to use Vue for the pages, so we could make the entire view reactive so we could easily fetch and update data with AJAX or websockets. I started building the status page view, but quickly became hesitant about the decision to use Vue. It didn’t feel like the right tool for the job.
Read more [sebastiandedeyne.com]
About a year ago, we released laravel-event-projector. It focused on adding projectors, an important concept in event sourcing, to Laravel.
After the release of the package, we continually kept improving it. We added aggregates, a way to test those, a brand new section in the our documentation that explains event sourcing from scratch, and DX improvements all across the board.
We now feel confident that the package is a good starting point for getting started with event sourcing in Laravel. That's why we're renaming the package to laravel-event-sourcing.
? If you need to process a lot of models, don't load them all into memory, but chunk them.
— Freek Van der Herten ? (@freekmurze) August 21, 2019
Laravel has a beautiful `each` method for this.https://t.co/cVWdpsGtQ1#laravel #php pic.twitter.com/ISW7XQcehx
Read more [twitter.com]
If you're using #Laravel Valet in Europe:
— Sander van Hooft (@SandervHooft) August 19, 2019
Just discovered "valet share --region=eu".
Ngrok seems to default to the US region otherwise. Major speed improvement.
Read more [twitter.com]
Unsung Laravel hero Joseph Silber opened up a very interesting PR to Laravel. Let's hope this one gets accepted.
Whereas the existing Collection class wraps a native array, the new LazyCollection class wraps a native iterator, while still providing most of the methods that we know and love from a regular collection.
Read more [github.com]
Mohammed Said shares some solid tips on optimizing costs when working in a serverless environment like Laravel Vapor
Laravel Vapor uses different AWS resources to efficiently get your application up and running in the serverless cloud. The building block of the whole thing is AWS Lambda, it's where the actual computing happens. Calculating the cost of the compute part for your application can be a bit confusing, so let's simplify it a bit with an example.
Read more [divinglaravel.com]
Jonathan Reinink has added a very usefull metric to Laravel debugbar
Last week at Laracon US I gave a talk titled Eloquent Performance Patterns. In that talk I used a custom Laravel Debugbar metric I created to track how many Eloquent models were being hydrated throughout a request. I've had a lot of people asking about this, so today I submitted a pull request to the Laravel Debugbar to add this as an official metric.
Read more [reinink.ca]
? Perf tip: if your web app ships large JSON-like configuration as JavaScript object literals, consider using JSON.parse instead. It’s much faster, especially for cold loads! https://t.co/C0oQ4BLnfz pic.twitter.com/p0WICUm7zx
— Mathias Bynens (@mathias) June 25, 2019
Read more [twitter.com]
Tim MacDonald, a freelance software developer based in Sydney, investigates how to make Laravel tests run faster. Turns out you a lot can be gained by caching the config.
I saw a conversation on Twitter the other day discussing how Laravel was slowing down a test suite. I decided I wanted to dig into this and see if there was anything to it.
Read more [timacdonald.me]
Ire Aderinokun, Front-End Developer and User Interface Designer, explains how you can Lighthouse in CI.
Until recently, I also hadn't setup an official performance budget and enforced it. This isn’t to say that I never did performance audits. I frequently use tools like PageSpeed Insights and take the feedback to make improvements. But what I had never done was set a list of metrics that I needed the site to meet, and enforce them using some automated tool.
Read more [bitsofco.de]
Jonathan Reinink wrote another awesome post on how to handle a complicated query.
I was asked recently how to calculate multiple totals (aggregates) in Laravel in the most efficient way. For example, maybe you have an email subscription service and want to display various totals based on your subscribers
Read more [reinink.ca]
When a request comes in your app will return a response. To create that response, your application has to do some work. Most likely queries will execute. This all takes some time. Wouldn't it be nice if the same request comes in, we can return the response the application has constructed previously?