
Introduction
Magento load testing is essential for any store that expects traffic spikes, seasonal promotions, flash sales, or steady day-to-day customer activity. Magento is a powerful e-commerce platform, but it can also be resource-intensive. Category pages with layered navigation, product detail pages with dynamic pricing, cart updates, customer authentication, and checkout flows all place different kinds of pressure on your infrastructure.
If you run a Magento 2 store, performance testing helps you answer critical questions before customers do:
- Can your storefront handle concurrent shoppers during a sale?
- Do product and category pages stay fast under load?
- Does the cart and checkout remain stable when traffic surges?
- Are customer login, search, and API endpoints becoming bottlenecks?
- Will your caching, database, and backend services scale properly?
With LoadForge, you can run cloud-based Magento load testing at scale using Locust-powered Python scripts. That means you can simulate realistic user journeys, distribute traffic globally, monitor performance in real time, and integrate performance testing into your CI/CD pipeline.
In this guide, you’ll learn how to build practical Magento load tests with realistic endpoint paths, session handling, customer login flows, and checkout-related activity.
Prerequisites
Before you begin load testing Magento with LoadForge, make sure you have the following:
- A Magento 2 store environment to test
- Preferably staging or pre-production
- Avoid running aggressive stress testing against production unless carefully planned
- A list of key storefront URLs and workflows
- Homepage
- Category pages
- Product pages
- Search
- Customer login
- Cart
- Checkout
- Test accounts for customer login scenarios
- Sample products with known SKUs and stock availability
- A payment and shipping setup that works in your test environment
- Permission to test and awareness of infrastructure limits
- LoadForge account for distributed load testing and reporting
It also helps to know whether your Magento store uses:
- Full-page cache such as Varnish
- Redis for sessions or cache
- Elasticsearch or OpenSearch for catalog search
- CDN and WAF layers
- Third-party modules that affect cart or checkout behavior
These components strongly influence Magento performance testing results.
Understanding Magento Under Load
Magento behaves very differently depending on the page type and whether a user is anonymous or authenticated.
Anonymous storefront traffic
Anonymous users often hit cached pages, especially:
- Homepage
- Category pages
- Product detail pages
- CMS content pages
If full-page caching is configured correctly, Magento can serve these pages efficiently. However, even cached pages may still depend on:
- CDN edge caching
- Varnish behavior
- Backend cache invalidation
- Dynamic blocks such as mini-cart, customer-specific pricing, or recommendations
A load test of these pages helps validate cache hit ratios and response times under concurrent traffic.
Authenticated customer traffic
Once users log in, Magento performance often changes. Customer-specific content may bypass some caching layers. Common pressure points include:
- Customer account login
- Wishlists
- Order history
- Cart updates
- Checkout shipping and payment steps
These workflows are more database-heavy and session-dependent, making them ideal candidates for deeper performance testing.
Search and catalog bottlenecks
Magento search and layered navigation can become expensive under load, especially with large catalogs. Common bottlenecks include:
- Elasticsearch/OpenSearch query latency
- Slow category filtering
- Large attribute sets
- Expensive sorting and faceting
- Custom product collections
Checkout bottlenecks
Checkout is often the most important part of Magento stress testing because revenue depends on it. Common issues include:
- Slow cart item updates
- Session locking
- Shipping method estimation delays
- Payment method retrieval latency
- Third-party fraud, tax, or shipping integrations
- Inventory checks and quote recalculations
A good Magento load test should include both browse-heavy traffic and transactional checkout flows.
Writing Your First Load Test
The best starting point is a storefront browsing scenario that simulates anonymous users visiting common pages. This gives you a baseline for Magento performance testing and helps identify whether your cache configuration is working.
Basic Magento storefront browsing test
from locust import HttpUser, task, between
class MagentoBrowsingUser(HttpUser):
wait_time = between(2, 5)
def on_start(self):
self.common_headers = {
"User-Agent": "LoadForge Magento Load Test",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
}
@task(3)
def homepage(self):
self.client.get("/", headers=self.common_headers, name="GET /")
@task(2)
def category_page(self):
self.client.get(
"/women/tops-women/jackets-women.html",
headers=self.common_headers,
name="GET category page"
)
@task(4)
def product_page(self):
self.client.get(
"/radiant-tee.html",
headers=self.common_headers,
name="GET product page"
)
@task(1)
def search_results(self):
self.client.get(
"/catalogsearch/result/?q=tee",
headers=self.common_headers,
name="GET search results"
)What this test does
This script simulates a typical anonymous Magento shopper who:
- Visits the homepage
- Browses a category page
- Opens a product page
- Performs a site search
These are some of the most important pages to test first because they reveal:
- Cache effectiveness
- Search performance
- Catalog rendering speed
- Frontend response time under load
In LoadForge, you can scale this script across multiple cloud load generators and observe real-time reporting for request rate, response times, failures, and percentile latency.
What to watch for
When running this first Magento load test, pay attention to:
- Median and p95 response times for category and product pages
- Error rates during search
- Throughput changes as user count increases
- Whether response times remain flat for cached pages
If homepage and product pages degrade quickly, caching or origin capacity may be insufficient.
Advanced Load Testing Scenarios
Once you have a baseline, the next step is to test more realistic Magento customer workflows. These scenarios are where performance issues typically become visible.
Advanced Load Testing Scenarios
Scenario 1: Customer login and account page access
Magento customer authentication is a common source of performance issues because it involves sessions, cookies, form keys, and customer-specific rendering.
The login form is typically submitted to /customer/account/loginPost/.
from locust import HttpUser, task, between
import re
class MagentoCustomerLoginUser(HttpUser):
wait_time = between(3, 6)
def on_start(self):
self.headers = {
"User-Agent": "LoadForge Magento Customer Test",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
}
self.email = "loadtest.customer1@example.com"
self.password = "Password123!"
def get_form_key(self, html):
match = re.search(r'name="form_key"\s+value="([^"]+)"', html)
return match.group(1) if match else None
@task
def login_and_view_account(self):
login_page = self.client.get(
"/customer/account/login/",
headers=self.headers,
name="GET login page"
)
form_key = self.get_form_key(login_page.text)
if not form_key:
login_page.failure("Could not extract Magento form_key")
return
payload = {
"form_key": form_key,
"login[username]": self.email,
"login[password]": self.password
}
with self.client.post(
"/customer/account/loginPost/",
data=payload,
headers={
**self.headers,
"Content-Type": "application/x-www-form-urlencoded",
"Referer": f"{self.host}/customer/account/login/"
},
allow_redirects=True,
name="POST customer login",
catch_response=True
) as response:
if "customer/account/logout" not in response.text and "My Account" not in response.text:
response.failure("Login may have failed")
self.client.get(
"/customer/account/",
headers=self.headers,
name="GET customer account"
)Why this matters
This scenario tests:
- Login page rendering
- CSRF form key extraction
- Session creation
- Customer account page performance
If Magento login slows down under load, customers may abandon the site before buying. This test is especially useful after enabling new customer modules, SSO integrations, or custom themes.
Scenario 2: Add to cart using Magento AJAX endpoint
A more realistic Magento load test should include cart operations. On many Magento 2 stores, adding to cart can involve product page rendering first, then posting to the cart endpoint.
For simple products, a common endpoint is /checkout/cart/add/ with a form key and product-specific parameters.
from locust import HttpUser, task, between
import re
class MagentoAddToCartUser(HttpUser):
wait_time = between(2, 5)
def on_start(self):
self.headers = {
"User-Agent": "LoadForge Magento Cart Test",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
}
self.product_url = "/radiant-tee.html"
self.product_id = "181"
self.super_attribute = {}
self.qty = "1"
def extract_form_key(self, html):
match = re.search(r'"formKey":"([^"]+)"', html)
if match:
return match.group(1)
match = re.search(r'name="form_key"\s+value="([^"]+)"', html)
return match.group(1) if match else None
@task
def view_product_and_add_to_cart(self):
product_page = self.client.get(
self.product_url,
headers=self.headers,
name="GET product page for cart"
)
form_key = self.extract_form_key(product_page.text)
if not form_key:
product_page.failure("Could not extract form_key from product page")
return
payload = {
"product": self.product_id,
"qty": self.qty,
"form_key": form_key
}
with self.client.post(
"/checkout/cart/add/",
data=payload,
headers={
**self.headers,
"Content-Type": "application/x-www-form-urlencoded",
"Referer": f"{self.host}{self.product_url}"
},
allow_redirects=True,
name="POST add to cart",
catch_response=True
) as response:
if "shopping cart" not in response.text.lower() and "cart" not in response.url.lower():
response.failure("Add to cart may have failed")
self.client.get(
"/checkout/cart/",
headers=self.headers,
name="GET cart page"
)Notes for real Magento stores
For configurable products, you may need additional fields such as:
super_attribute[93]selected_configurable_optionrelated_product
If your theme uses AJAX add-to-cart, the frontend may call custom endpoints or Magento controller routes with JSON responses. In that case, inspect real browser network traffic and reproduce the exact request pattern in Locust.
Scenario 3: Magento REST API checkout-related flow
Many Magento stores use REST APIs for frontend components, mobile apps, PWA storefronts, or custom integrations. Testing these APIs is critical if your store relies on headless or hybrid architecture.
This example simulates a guest cart workflow using Magento REST endpoints.
from locust import HttpUser, task, between, SequentialTaskSet
import json
class GuestCheckoutFlow(SequentialTaskSet):
def on_start(self):
self.headers = {
"User-Agent": "LoadForge Magento API Test",
"Content-Type": "application/json",
"Accept": "application/json"
}
self.cart_id = None
@task
def create_guest_cart(self):
with self.client.post(
"/rest/default/V1/guest-carts",
headers=self.headers,
data="",
name="POST create guest cart",
catch_response=True
) as response:
if response.status_code == 200:
self.cart_id = response.json()
else:
response.failure(f"Failed to create guest cart: {response.status_code}")
@task
def add_item_to_cart(self):
if not self.cart_id:
return
payload = {
"cartItem": {
"quote_id": self.cart_id,
"sku": "WS12-M-Orange",
"qty": 1
}
}
self.client.post(
f"/rest/default/V1/guest-carts/{self.cart_id}/items",
headers=self.headers,
data=json.dumps(payload),
name="POST guest cart add item"
)
@task
def estimate_shipping(self):
if not self.cart_id:
return
payload = {
"address": {
"country_id": "US",
"region": "California",
"region_id": 12,
"postcode": "90210"
}
}
self.client.post(
f"/rest/default/V1/guest-carts/{self.cart_id}/estimate-shipping-methods",
headers=self.headers,
data=json.dumps(payload),
name="POST estimate shipping"
)
@task
def set_shipping_information(self):
if not self.cart_id:
return
payload = {
"addressInformation": {
"shipping_address": {
"firstname": "Load",
"lastname": "Tester",
"street": ["123 Test Street"],
"city": "Beverly Hills",
"region": "California",
"region_id": 12,
"postcode": "90210",
"country_id": "US",
"telephone": "5551234567"
},
"billing_address": {
"firstname": "Load",
"lastname": "Tester",
"street": ["123 Test Street"],
"city": "Beverly Hills",
"region": "California",
"region_id": 12,
"postcode": "90210",
"country_id": "US",
"telephone": "5551234567"
},
"shipping_carrier_code": "flatrate",
"shipping_method_code": "flatrate"
}
}
self.client.post(
f"/rest/default/V1/guest-carts/{self.cart_id}/shipping-information",
headers=self.headers,
data=json.dumps(payload),
name="POST shipping information"
)
class MagentoApiUser(HttpUser):
wait_time = between(1, 3)
tasks = [GuestCheckoutFlow]Why API testing matters for Magento
This kind of Magento performance testing is especially valuable for:
- Headless Magento storefronts
- Mobile checkout flows
- PWA Studio implementations
- Third-party frontend frameworks
- Integration-heavy stores
API load testing can expose problems that traditional page-based tests miss, including:
- Slow quote creation
- Inventory validation delays
- Shipping calculation bottlenecks
- Checkout service failures under concurrency
Analyzing Your Results
After running Magento load tests in LoadForge, focus on both technical metrics and business-critical user flows.
Key metrics to review
Response times
Look at:
- Average response time
- p95 and p99 latency
- Maximum response time
For Magento, p95 is often more useful than averages because a small number of slow requests can damage checkout conversion.
Error rates
Investigate any spikes in:
- 4xx errors from invalid sessions, CSRF issues, or bad payloads
- 5xx errors from PHP-FPM, Nginx, Apache, or upstream services
- Timeouts during cart, search, or checkout
Throughput
Measure how many requests per second your Magento store can sustain before latency sharply increases.
Endpoint-specific performance
Break down results by request name:
- GET homepage
- GET category page
- GET product page
- POST customer login
- POST add to cart
- POST estimate shipping
This helps you isolate whether the bottleneck is in browsing, authentication, cart logic, or checkout APIs.
What good results look like
For many Magento stores, healthy load testing results include:
- Cached pages staying consistently fast under load
- Search remaining stable without dramatic latency spikes
- Add-to-cart and login flows completing without rising error rates
- Checkout APIs staying within acceptable SLA thresholds
Use LoadForge reporting effectively
LoadForge makes Magento stress testing easier with:
- Real-time reporting during test execution
- Distributed testing from global test locations
- Cloud-based infrastructure for generating realistic traffic at scale
- Easy comparison across test runs
- CI/CD integration for automated performance regression testing
If you’re validating a release, compare your latest run against a known-good baseline and flag regressions in category, cart, or checkout performance.
Performance Optimization Tips
Magento optimization should always be guided by load testing data rather than guesswork. Here are practical areas to review when performance testing reveals issues.
Improve caching
For anonymous traffic, verify:
- Full-page cache is enabled
- Varnish is correctly configured
- Cacheable pages are not accidentally bypassed
- CDN caching rules are effective
If product and category pages are slow under load, caching is often the first place to investigate.
Optimize PHP and application resources
Review:
- PHP-FPM worker counts
- Memory limits
- OPcache settings
- Slow application code in custom modules
Magento can become CPU-bound quickly if PHP workers are exhausted.
Tune the database
Watch for:
- Slow quote and sales queries
- Lock contention during checkout
- Missing indexes
- Heavy catalog queries
- Excessive writes from session or cart operations
Cart and checkout slowdowns often trace back to MySQL pressure.
Tune search infrastructure
If search or layered navigation is slow:
- Review Elasticsearch/OpenSearch cluster health
- Reduce expensive aggregations
- Optimize searchable attributes
- Limit unnecessary facets and sorting options
Audit third-party extensions
Many Magento performance issues come from plugins that:
- Add extra observers
- Trigger synchronous API calls
- Recalculate totals excessively
- Inject dynamic content into cacheable pages
Load testing is one of the fastest ways to identify extension-related bottlenecks.
Test realistic traffic mixes
A Magento store rarely receives only homepage traffic. Use a realistic blend of:
- 60–70% browsing traffic
- 10–20% search traffic
- 10–15% cart activity
- 5–10% login and checkout actions
This provides more trustworthy performance testing results.
Common Pitfalls to Avoid
Magento load testing can produce misleading results if the test is not realistic.
Testing only cached pages
If you only test the homepage and category pages, you may conclude the store performs well while cart and checkout are actually failing. Always include transactional flows.
Ignoring form keys and sessions
Magento uses CSRF form keys and session cookies extensively. Hardcoding requests without handling these values often leads to invalid tests and false failure rates.
Using unrealistic product data
Make sure your scripts use:
- Real SKUs
- Valid product IDs
- In-stock products
- Correct configurable options where needed
Otherwise, add-to-cart and checkout tests won’t reflect real customer behavior.
Not separating guest and authenticated traffic
Guest users and logged-in customers can place very different loads on Magento. Test both separately and together.
Overlooking search and filters
Catalog search and layered navigation are common Magento bottlenecks. Don’t limit your performance testing to static URLs.
Running tests without monitoring backend systems
Load testing data is strongest when combined with infrastructure metrics such as:
- CPU
- Memory
- PHP-FPM utilization
- Database load
- Cache hit ratios
- Elasticsearch latency
Stress testing production without safeguards
Magento stress testing can affect real shoppers, inventory, and order systems. Use staging where possible, and if production testing is necessary, coordinate carefully with operations teams.
Conclusion
Magento is a feature-rich e-commerce platform, but that flexibility comes with performance complexity. Load testing Magento helps you uncover slow category pages, unstable search, cart bottlenecks, login issues, and checkout failures before they affect revenue.
With LoadForge, you can build realistic Locust-based Magento load tests, simulate traffic from global test locations, monitor results in real time, and scale your performance testing using cloud-based infrastructure. Whether you’re preparing for a major sale, validating a new extension, or adding automated performance checks to CI/CD, LoadForge gives you a practical way to test Magento with confidence.
Try LoadForge to run your next Magento load test and see how your store performs under real-world traffic.
LoadForge Team
LoadForge is a load and performance testing platform built on Locust. Our team has been shipping load tests against production systems since 2018, and we write these guides from real customer engagements.
Related guides
Keep going with more guides from the same category.

Contentful Load Testing: How to Load Test Contentful APIs with LoadForge
Learn how to load test Contentful APIs with LoadForge to measure content delivery performance and handle traffic surges.

Ghost Load Testing: Performance Testing Ghost CMS with LoadForge
Learn how to load test Ghost CMS with LoadForge to benchmark publishing performance and keep content delivery fast under load.

Medusa Load Testing: How to Stress Test Medusa Commerce with LoadForge
Discover how to load test Medusa commerce apps with LoadForge to improve API speed, cart flows, and order handling at scale.