Optimizing Shopware 6 Checkout Performance with Callgraph Tracepoints

A few weeks ago, Andrey from Ecommlab contacted me to ask me about a strategy to get performance insights from Tideways into Shopware 6 checkout. 

The store of our joint customer “Bär Schuhe” was slow for customers during the order confirmation process.

Optimizing checkout performance is important but much more difficult than product or category pages for two reasons:

  • Customers do not visit them nearly as often as they view products/categories.
  • As a developer it is difficult to put them into production without causing payment transactions and order cancellations in the ERP system. 

In this blog post, we will go through an optimization of the order confirmation step in the checkout process, reducing the 95% percentile performance from 1-2 minutes to 6-9 seconds.

Identifying the Bottleneck with a Callgraph Tracepoint

Looking at Timeline profiling traces collected from customers of the “Bär Schuhe” store, nothing immediately jumped out as a bottleneck.

To get more detailed profiling data at the function level, we created a callgraph tracepoint and, after waiting for the results, examined the slowest collected callgraph to identify the bottleneck. 

One plugin stood out, taking 66% of a 45-second request and causing approximately 50,000 objects to be created from database rows. This is a custom plugin that connects the store to the ERP system. The combination of slowness and excessive database load warrants an investigation of the plugin’s code:

There are a lot of associations being eagerly loaded for the order transaction, which makes us wonder which one is responsible for the majority of the 50,000 or so database objects being created. 

Comparing this piece of plugin code with other places in the Shopware core and available plugins, we determined that the bottleneck is most likely caused by eagerly loading the state machine history.

Confirming the Optimization Works

Andrey confirmed that removing this line did not break the code and rolled it out to production, where we confirmed our hunch: Performance for the order completion step of the checkout dropped from up to 2 minutes to a maximum of 17 seconds. 

The following comparison shows that the plugin code is now 29 seconds faster overall, and that the creation of 50,000 database objects was reduced, accounting for the majority of the time savings, 16 seconds.


This solves the biggest performance bottleneck in the order confirmation process code with a one-line change. 

Further improvements to the checkout were made to bring the user experience to an acceptable level, but each had a much smaller impact overall than this one.

This shows how based on insights from a Profiler, you can start optimizing the biggest bottlenecks first and minimize the time spent optimizing.

What an AI would never be able to tell you the way we can! Follow us on LinkedIn or X and subscribe to our newsletter to take a deep dive into technical issues surrounding PHP performance.

You’ll never know until you try … our free trial!

Benjamin Benjamin 10.04.2024