DEV Community

Cover image for We Pushed a Website to 4,000 Concurrent Users: Lessons From a Load Test
cenk
cenk

Posted on Originally published at c3nk.com

We Pushed a Website to 4,000 Concurrent Users: Lessons From a Load Test

Before going live, the new server environment of a high-traffic corporate website was put through a systematic load test with JMeter. The question was simple: "What happens if thousands of people hit the site at the same time during a busy period or a major announcement?" This post walks through the problem definition, the methods we tried, and, most importantly, what the numbers actually told us. All organization, address, and personal details have been anonymized.

Problem Definition

A new server environment had been prepared, but whether it could handle peak traffic was unknown. The question was clear: Up to how many concurrent users does the system run healthily, at what point does it start to crack, and where exactly is the bottleneck?

Learning the answer in production, with real users, is the most expensive route. So instead we generated the load in a controlled way, inside an isolated test environment that was an exact replica of production. The work was carried out over a summer morning, in sessions of a few hours each.

Test tool: Apache JMeter 5.6.3

Hardware: 16 vCPU / 32 GB RAM

Target load: 4,000 concurrent virtual users

Ramp-up: 240 seconds

In other words, we climb from 0 to 4,000 users over four minutes and watch where in that climb the system cracks.

A realistic visitor scenario

A load test is only as valuable as its imitation of a real user. Hammering the homepage alone is easy but misleading. So we modeled a typical visitor journey:

  1. View the homepage
  2. Move to a listing page (announcement/news feed)
  3. Open a content detail page
  4. Download a PDF (a heavy static file)
  5. Run a search from the search box

With random search terms and reasonable think-times, the scenario was brought behaviorally close to a real user. These five steps spread the load across three distinct layers: the web server (Apache) serving static content, the application layer rendering dynamic pages, and the database running the search/listing queries.

Starting Point: Everything Was Red

The first runs, on the untuned environment, were grim. One of the early runs looked like this:

Metric Value
Average response time ~105 seconds
Error rate 49.8%
Slowest request ~289 seconds

An average response time north of a hundred seconds and one in every two requests failing; this is exactly the "the site is up but unusable" state. The good news: this is precisely what a load test is for, to trigger that collapse in a controlled environment before any real user experiences it in production. From here on, it was a matter of chasing the problem layer by layer.

Method 1 - Web Server: Comparing 8 Configurations

Most of the bottleneck sat in the web server layer. Apache's MPM (Multi-Processing Module) settings, including how many workers to start, how many to keep spare, and how many requests to serve at once, directly determine how many people the system can carry simultaneously. A total of 8 different configurations were tried.

We evaluated the configurations against four metrics:

  • First Error → At which concurrent-user count the first error appeared. Higher = better (the system stayed clean longer).
  • Stop Error → The user count at which errors became unacceptable / the test was stopped. 4,000 = it held all the way to the end of the load.
  • Total Error % → The run as a whole. Lower = better.
  • RAM → Memory used (out of 32 GB). A stability indicator.

The configurations are given anonymously, labeled A-H:

Config Start MinSpare MaxSpare ServerLimit MaxReqWorkers MaxConn/Child First Error ↑ Stop ↑ Error % ↓ RAM (GB)
A (current) 50 0 50 100 4000 0 2800 3800 10% 30
B 20 0 100 20000 8000 10000 2000 3000 50% 10
C 4 0 75 250 1024 64 1500 2500 50% 5
D ⭐ 50 50 100 4000 4000 0 2800 4000 12% 28
E 50 50 100 4000 4000 5000 2300 4000 15% 20
F (low limits) 5 5 10 0 480 1000 700 1500 60% 1
G (generic preset) 4 0 100 100 8000 0 1100 4000 80% 2
H 50 50 100 4000 4000 2500 2500 4000 15% 30

The story the table tells

The numbers deliver a handful of very clear lessons:

1. The "recommended" generic settings were the worst (G). The "generic preset" configuration, lifted from online tuning guides, came in dead last with 80% errors. Its low 2 GB RAM usage is deceptive; the system spends few resources not because it carries the load, but because it rejects most of the requests. This is the single most important warning a load test gives: low resource usage is not always good news.

2. Limits set too small die early (F). The low-limit configuration with MaxRequestWorkers = 480 began to collapse at just 700 users. With a target of 4,000 users, a setting that can serve at most 480 requests at once is mathematically inadequate from the start.

3. The winner was D, but its edge lies in a subtlety. Configuration D was the only balanced profile that held to the end of the load (4,000), produced the latest first error (2,800 users), and kept the error rate at a reasonable 12%. The formula that won it:

  • StartServers = 50 + MinSpareServers = 50 → Workers wait pre-warmed; when the load wave hits, no time is lost spinning up processes from scratch.
  • ServerLimit = 4000 + MaxRequestWorkers = 4000 → Capacity scaled exactly to the target load.
  • MaxConnectionPerChild = 0 → Workers are not recycled after a fixed number of requests.

4. Worker recycling was harmful under load (E and H). E (MaxConn/Child = 5000) and H (= 2500) had almost identical settings to D; the only difference was that workers were periodically killed and restarted. The result: the first error slipped from D's 2,800 down to 2,300-2,500. Recycling workers in the middle of heavy load fluctuates capacity exactly when it is needed most. A setting that is useful under light traffic can trip you up at peak load.

5. The current configuration (A) was actually not bad. The current setting, which can be taken as the baseline, delivered the lowest error rate (10%) but could not hold to the end of the load (it stopped at 3,800). D, at the cost of a small increase in error rate (10% -> 12%), kept the system alive all the way to 4,000, a reasonable trade for resilience.

Method 2 - Database: The Bottleneck Was Not Here

While the web server layer was fighting, the database layer stayed surprisingly calm. Two separate tuning rounds were tried:

Metric DB Round 1 DB Round 2
First error (users) 3800 3900
Held until 4000 4000
RAM (GB) 31 30
Error rate 1% 1%
Critical listing query time 0.6 s 0.5 s

In both rounds the database held to the end of the load with just 1% errors. That says a lot: the real bottleneck was not the database, but the web server layer. The second tuning round (cache and working-memory settings, parallel worker counts, and so on) pulled the most-called listing query from 0.6 seconds down to 0.5 seconds, a small but concrete improvement.

A detail worth not missing

One of the most frequently executed queries contained a search with a leading wildcard (LIKE '%...%') on a text field. This pattern has a significant drawback: leading-wildcard searches cannot use any index and force a full table scan on every call. While 0.5 seconds looks acceptable today, this query will slow down linearly as the underlying table grows. Modeling this relationship through a separate table in the future (or at least considering full-text search / a suitable index structure) is the clearest opportunity to speed this query up for good.

Findings and Lessons Learned

The test in three sentences:

  1. Winning configuration: D. With capacity scaled exactly to the target load (4,000), workers pre-warmed, and no recycling under load, this profile was the only balanced option that both produced the latest first error and held to the end of the load.
  2. RAM hit the ceiling. The best configurations used 28-30 GB of the 32 GB. Such a thin margin puts the system at risk at the slightest traffic surge. Upgrading memory to 48 GB is recommended; this would give breathing room to both the web server workers and the database cache.
  3. The bottleneck was in the web layer, not the database. The database held comfortably at 1% errors; the bulk of the optimization effort rightly went to the web server settings.

General takeaways

  • Don't blindly trust generic "best practice" settings. The "recommended" configuration pulled from the internet produced the worst result (80% errors) in this environment. The right setting is found by measuring against the actual hardware and real traffic profile.
  • Low resource usage can be misleading. If the system is spending little RAM, it may be because it is rejecting most requests, not because it is carrying the load efficiently. Always read resource metrics together with the error rate.
  • Scale capacity to the target load. MaxRequestWorkers and ServerLimit should be set according to the expected concurrent-user count, neither too high (wasted resources and instability) nor too low (early collapse).
  • The setting optimized for peak load differs from the one for normal load. "Housekeeping" behaviors like worker recycling (MaxConnectionPerChild) can be harmful exactly when the most capacity is needed.
  • Don't assume the bottleneck; measure it. While everyone assumed "the slowness must be the database," the data showed the bottleneck was in the web layer. Measuring layer by layer directs the effort to the right place.

With this configuration, the system will run noticeably more stably and sustainably under current traffic scenarios. The next step is to repeat the test after the recommended RAM upgrade and to measure the index optimization of the critical query.

Field notes - summer 2025.

Cover photo by Frantisek Duris on Unsplash.

Top comments (0)