How to benchmark Magento with Apache JMeter
STEP1: Preparing the Magento server
Install a clean Magento test site
Generating test data for example
bin/magento setup:perf:generate-fixtures /var/www/html/magento2/setup/performance-toolkit/profiles/ce/small.xml
Configure Magento site for benchmarking:
Go to Stores > Configuration > General > Web > Search Engine Optimization - Use Web Server Rewrites “Yes”
Go to Stores > Configuration > Catalog > Catalog > Storefront - Use Flat Catalog Category “Yes”
Use Flat Catalog Product “Yes”Go to Stores > Configuration > Advanced > Admin > Security - Admin Account Sharing “Yes”
Go to Stores > Configuration > Advanced > Developer - JavaScript Settings - Merge JavaScript Files “Yes”
Merge CSS Files “Yes”Indexers setup in "Update by schedule" mode: Follow System > Tool > Index Management Set "Update by schedule" for all idexers
Save configuration, perform reindex and clean Cache
STEP2: Installation of JMeter
Prerequisites:
Check if Java is already installed (install if not)
java -version
Install Apache Web Server
apt-get install apache2 -y systemctl start apache2 systemctl enable apache2
Install Apache JMeter
Go to the Download Apache JMeter page and download JMeter in the Binaries section
Unzip the archive
Install the JSON plugin for JMeter
STEP3: Run JMeter
Run scenario via console
There are two JMeter scenarios located in setup/performance-toolkit
folder: benchmark.jmx
and benchmark_2015.jmx
(legacy version).
The following parameters can be passed to the benchmark.jmx
scenario:
Parameter Name | Default Value | Description |
---|---|---|
host | localhost | URL component 'host' of application being tested (URL or IP). |
base_path | / | Base path for tested site. |
admin_path | admin | Admin backend path. |
admin_user | admin | Admin backend user. |
admin_password | 123123q | Admin backend password. |
customer_password | 123123q | Storefront customer password. |
customers_page_size | 50 | Page size for customers grid in Magento Admin. |
files_folder | ./files/ | Path to various files that are used in scenario ( |
loops | 1 | Number of loops to run. |
frontendPoolUsers | 1 | Total number of Frontend threads. |
adminPoolUsers | 1 | Total number of Admin threads. |
browseCatalogByGuestPercentage | 30 | Percentage of threads in Frontend Pool that emulate catalog browsing activities. |
browseCatalogByCustomerPercentage | 0 | Percentage of threads in Frontend Pool that emulate catalog browsing activities. |
siteSearchPercentage | 30 | Percentage of threads in Frontend Pool that emulate catalog search activities. |
searchQuickPercentage | 60 | Percentage of threads in Frontend Pool that emulate catalog search activities. |
searchQuickFilterPercentage | 30 | Percentage of threads in Frontend Pool that emulate catalog search activities. |
searchAdvancedPercentage | 10 | Percentage of threads in Frontend Pool that emulate catalog search activities. |
checkoutByGuestPercentage | 4 | Percentage of threads in Frontend Pool that emulate checkout by guest. |
checkoutByCustomerPercentage | 4 | Percentage of threads in Frontend Pool that emulate checkout by customer. |
addToCartByGuestPercentage | 28 | Percentage of threads in Frontend Pool that emulate abandoned cart activities. |
addToWishlistPercentage | 2 | Percentage of threads in Frontend Pool that emulate adding products to Wishlist. |
compareProductsPercentage | 2 | Percentage of threads in Frontend Pool that emulate products comparison. |
productCompareDelay | 0 | Delay (s) between iterations of product comparison. |
promotionRulesPercentage | 10 | Percentage of threads in Admin Pool that emulate creation of promotion rules. |
adminPromotionsManagementDelay | 0 | Delay (s) between creation of promotion rules. |
adminCategoryManagementPercentage | 10 | Percentage of threads in Merchandising Pool that emulate category management activities. |
adminProductEditingPercentage | 35 | Percentage of threads in Merchandising Pool that emulate product editing. |
adminProductCreationPercentage | 25 | Percentage of threads in Merchandising Pool that emulate creation of products. |
adminPromotionRulesPercentage | 15 | Percentage of threads in Admin Pool that emulate admin rules creating activities. |
adminCategoryManagementDelay | 0 | Delay (s) between iterations of category management activities. |
apiProcessOrders | 5 | Number of orders for process in Admin API - Process Orders. |
adminEditOrderPercentage | 15 | Percentage of threads in Admin Pool that emulate order edit. |
csrPoolUsers | 0 | Users of Customer Support Request (CSR) Pool. |
othersPoolUsers | 0 | Users of Others Pool. |
browseCustomerGridPercentage | 10 | Percentage of threads in CSR Pool that emulate customers browsing activities. |
adminCreateOrderPercentage | 70 | Percentage of threads in CSR Pool that emulate creation of orders. |
adminReturnsManagementPercentage | 20 | Percentage of threads in CSR Pool that emulate creation/processing of returns. |
adminCreateProcessReturnsDelay | 0 | Delay (s) between creation of returns. |
wishlistDelay | 0 | Delay (s) between adding products to Wishlist. |
categories_count | 100 | Total number of categories that are be used in scenario. |
simple_products_count | 30 | Total number of simple products that are be used in scenario. |
Parameters must be passed to the command line with the J
prefix:
-J{parameter_name}={parameter_value}
For example, you can run the B2C scenario via console with 90 threads for the Frontend Pool and 10 threads for the Admin Pool:
Run JMeter scenario via GUI
Note: Use the GUI mode only for scenario debugging and viewing reports. Use console mode for real-life load testing, because it requires significantly fewer resources.
Change directories and run Jmeter
Click File -> Open (Ctrl+O) and select
benchmark.jmx
file or drag and drop thebenchmark.jmx
file in the opened GUI.
In the root node (Performance Test Plan) in the left panel, you can change User Defined Variables listed in the previous section. To run a script, click the Start button (green arrow in the top menu).
STEP4: Output
The results of running a JMeter scenario are available in the View Results Tree and Aggregate Report nodes in the left panel of the JMeter GUI.
View Results Tree