Blog

Embedding Dynamic Content Without Sucking

Published: December 18, 2020

Tags:

A common pattern for embedding dynamic content on the web looks something like this:

<div id="content-will-go-here"></div>
<script src="//vendor.com/inject-content.js"></script>

In this example, the <div> is initially empty on the page, and then the JavaScript pulls content from a 3rd party and dynamically injects it into the <div>.

While this strategy makes sense in principle, there are a number of issues with the markup presented above. In this post we’ll look at how to fix up this approach so that is no longer sucks.

Testing Log Output in Go with logrus

Published: November 15, 2020

Tags:

logrus provides a nice facility for testing logging, which is documented in the README. While the README gives you a general idea of the offering, it doesn’t provide any opinions on how to structure your project to support log testing, leaving you on your own to decide on a strategy. Here I wanted to show you the strategy I came up with and am currently using on my project dbanon.

Analyzing Web Vitals Stored in Google Analytics

Published: November 8, 2020

Google Analytics is a convenient (free) place to store Web Vitals “field measurements”. The Google Chrome team has provided extensive instructions on how to do this.

When it comes to analyzing the data, the instructions are a bit more vague. If you spend some time trying to dig into the data, one thing will quickly become clear…the Google Analytics UI is not a good tool for this.

Here I’ll cover my approach, which involves extracting the data via the Google Analytics Reporting API and analyzing it with pandas.

Gatling disableFollowRedirect without KO

Published: September 11, 2020

Tags:

I’m currently working on a Gatling simulation which involves sending traffic to an endpoint that issues an HTTP 307 response. For this load test I want to send requests to this endpoint, but I don’t want Gatling to follow the redirect. You can instruct Gatling to not follow the redirect by calling disableFollowRedirect:

http("My request")
    .get("/redirecting-url")
    .disableFollowRedirect

However, doing this will cause Gatling to flag the request as a KO, when the endpoint issues a 307 response.

Magento Image Cache Lock Contention Issue

Published: June 17, 2020

Tags:

During a recent Magento v2.3.5 upgrade (which was ultimately rolled back), we saw severely degraded performance when rolling back the the previous version. In New Relic we could see the most time consuming transaction was /unknown.

Screenshot most time consuming transactions in New Relic

Reviewing the transaction traces we could see that these were requests to generate resized images, and that almost all of the time was being spent on the Magento\Framework\Filesystem\Driver\File::fileLock function.

Screenshot of transaction trace in New Relic

Clearing a Backlog of MySQL Queries

Published: June 12, 2020

Tags:

WARNING Proceed with caution

Sometimes, for one reason or another, MySQL may get in a state where it has a massive backlog of queries to process. In these types of situations, your application will likely be experiencing major performance issues. Additionally MySQL (and your application) will likely struggle to regain stability without human intervention. While restarting the MySQL process could be an option, that comes with a lot of risk. Another option, is to selectively kill certain queries.