Posts tagged with optimization

How to delete 900 million records in MySQL without shooting yourself in the foot

flareapp.io

When reviewing the contents of the database of Flare, we encountered a table with 1 billion records. Technically that isn't a problem. Flare runs on Vapor and uses an Aurora database, so it can handle that scale. But of course, there's a cost for storing that many records.

We dove in and concluded that we could safely delete about 900 million records. They all were created before a specific date.

Read more [flareapp.io]

Join thousands of developers

Every two weeks, I share practical tips, tutorials, and behind-the-scenes insights from maintaining 300+ open source packages.

No spam. Unsubscribe anytime. You can also follow me on X.

Creating custom relations in Laravel

stitcher.io

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]

Event store optimizations in laravel-event-sourcing

by Freek Van der Herten – 5 minute read

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.

Read more

Optimizing JavaScript packages for tree shaking

madewithlove.be

In a new post at the madewithlove blog, Geoffrey Dhuyvetters explains how you can organize your code so a bundler can make it as small as possible.

As an author of (open source) packages, I think you have the responsibility to protect the bundle size of your package consumer. When you publish a package that exports a whole range of modules (for example lodash, ramda, date-fns…) you want to make sure the package is exported in such a way that the consumer of your package (mostly bundlers) can optimize size.

Read more [madewithlove.be]

20 lines of code that will beat A/B testing every time

stevehanov.ca

In an older but still post, Steve Hanov explains a nice algorithm to test out new features on your audience. I don't now if this approach will yield better results, but it sure is an interesting idea.

In recent years, hundreds of the brightest minds of modern civilization have been hard at work not curing cancer. Instead, they have been refining techniques for getting you and me to click on banner ads. It has been working. Both Google and Microsoft are focusing on using more information about visitors to predict what to show them. Strangely, anything better than A/B testing is absent from mainstream tools, including Google Analytics, and Google Website optimizer. I hope to change that by raising awareness about better techniques.

Read more [stevehanov.ca]

A new website for Spatie: backend highlights

by Freek Van der Herten – 7 minute read

For the first time in 4 years we completely redesigned our company website. We launched it today. The site is a simple Laravel app with some technical niceties. True to form we also open sourced the app, you can find the code in this repo on GitHub. In this blogpost I'd like you to give you a tour…

Read more

Improving the performance of spatie/laravel-permission

Barry van Veen recently fixed an interesting performance issue at our permissions package.

Recently I was investigating the performance of an application we have built at SWIS. To my surprise, one of the most excellent costly methods was part of the spatie/laravel-permission package. After reading some more it was clearly a performance issue that could be improved upon. Since the solution was already clearly outlined it was quite easy to code it and submit a pull request.

https://barryvanveen.nl/blog/46-improving-the-performance-of-spatie-laravel-permission

Read more

Optimizing colinodell/json5 with Blackfire

Collin O' Dell, member of the PHP League, shares how he was able to significantly improve the performance his json5 package using Blackfire profiling.

Back in November I released colinodell/json5 - a JSON5 parser for PHP. It's essentially a drop-in replacement for PHP's json_decode() function, but it allows things like comments, trailing commas, and more.

...

I always knew that a PHP-based implementation would be slower than PHP's native C implementation, but execution time measured in minutes was completely unacceptable!

So I fired up Blackfire (which I've previously used to optimize league/commonmark) and got to work.

https://www.colinodell.com/blog/201801/optimizing-colinodelljson5-blackfire

Read more

The Cost Of JavaScript

Probably you know that that keeping the disk & transfer size of a JavaScript file low is pretty important. But have you considered the time needed to parse and compile the code? In this great post on Medium Addy Osmani, an engineer at Google, explains the complete cost of having JavaScript on your page.

As we build sites more heavily reliant on JavaScript, we sometimes pay for what we send down in ways that we can’t always easily see. In this post, I’ll cover why a little discipline can help if you’d like your site to load & be interactive quickly on mobile devices. tl;dr: less code = less parse/compile + less transfer + less to decompress

https://medium.com/dev-channel/the-cost-of-javascript-84009f51e99e

Read more

A little story about the `yes` Unix command

yes is a Unix command that will spit out and infinite stream of y's. In a post on his blog Matthias Endler, an engineer at trivago, shares that there's more than meets the eye to make this happen in a performant way.

The trivial program yes turns out not to be so trivial after all. It uses output buffering and memory alignment to improve performance. Re-implementing Unix tools is fun and makes me appreciate the nifty tricks, which make our computers fast.

https://matthias-endler.de/2017/yes/

Read more

Essential image optimization

Addy Osmani, a Google Chrome engineer, recently published a e-book on image optimization. You can read it in it's entirety here: https://images.guide/

Images take up massive amounts of internet bandwidth because they often have large file sizes. According to the HTTP Archive, 60% of the data transferred to fetch a web page is images composed of JPEGs, PNGs and GIFs. As of July 2017, images accounted for 1.7MB of the content loaded for the 3.0MB average site.

Per Tammy Everts, adding images to a page or making existing images larger have been proven to increase conversion rates. It's unlikely that images will go away and so investing in an efficient compression strategy to minimize bloat becomes important.

If you need to optimize images in your PHP application take a look at our image optimization package. If you're a Laravel user you'll be happy to know that there's also a Laravel version of the optimizer. Our Laravel Medialibrary also comes with built-in support for optimizing images.

Read more

Easily optimize images using PHP (and some binaries)

by Freek Van der Herten – 7 minute read

Our recently released image-optimizer package can shave off some kilobyes of PNGs, JPGs, SVGs and GIFs by running them through a chain of various image optimization tools. In this blog post I'll tell you all about it. First, here's a quick example on how you can use it: use…

Read more

Performant Laravel

Chris Fideo, of Servers For Hackers and Shipping Docker, published a new free video serious on optimizing performance for Laravel apps. He shows how to use the built in artisan commands such as config:cache and route:cache,how to optimize queries, build up good indexes and how to add an object cache in a clean way.

There are some super common reasons your Laravel app might be slow. This course shows you how to avoid speed issues with simple changes you can implement immediately.

https://serversforhackers.com/laravel-perf

Chris is also a working on a paid course on how to scale Laravel apps. If you want to stay in the loop for that one, subscribe to his newsletter.

Read more