All posts
Liferay · 10 min read · Jun 6, 2026

Debugging slow Liferay pages in production

Debugging slow Liferay pages in production

Production slowness is rarely mysterious once you stop guessing and start measuring. The instinct to add a cache or bump JVM memory before knowing where the time goes is how teams spend a week fixing the wrong layer. A slow Liferay page is almost always slow in one specific place, and the job is to find that place with evidence.

Measure before you change anything

Start by capturing where the time is actually spent. A single slow request, traced end to end, tells you more than hours of speculation. Liferay and the surrounding stack expose enough signal to localize the problem quickly.

  • Browser Network tab: is the time in the server response, or in downloading assets afterward?
  • Server access logs: measure the response time of the HTML document alone, isolated from static resources.
  • Database slow query log: enable it temporarily to catch queries crossing a threshold during the slow request.
  • Thread dumps: take three a few seconds apart under load to see where threads are actually blocked.

The usual suspects

Across many production portals, slow pages cluster around a small number of causes. Checking them in rough order of frequency resolves most cases:

SymptomLikely causeFirst check
One page slow, others fineExpensive query or N+1 in that page's logicDB slow query log
All pages slowCache misconfiguration or undersized heapCache hit rate, GC logs
Slow only under loadThread pool or connection pool exhaustionThread dumps, pool metrics
Slow first hit, fast afterCold cache or lazy initializationWarm-up behavior
Match the symptom pattern to the layer before touching configuration.

Find the N+1 query

The most common single cause is a loop that issues one query per item. It is invisible with ten records and catastrophic with ten thousand. A quick way to confirm it is to log query counts per request and look for numbers that scale with the data on the page.

java
// Symptom: query count grows with the number of articles
for (JournalArticle article : articles) {
    // each call hits the database again
    User author = userLocalService.getUser(article.getUserId());
    render(article, author);
}

// Fix: batch the lookup once, then resolve in memory
Set<Long> userIds = articles.stream()
    .map(JournalArticle::getUserId).collect(toSet());
Map<Long, User> authors = userLocalService
    .getUsers(userIds).stream()
    .collect(toMap(User::getUserId, u -> u));
Collapsing per-item queries into a single batch is often the biggest single win.

Build a repeatable checklist

Once you have solved a few of these, the value is in writing down the sequence so the next incident is faster: trace one request, isolate the slow layer, confirm with the matching metric, then change exactly one thing and re-measure. Slow-page debugging becomes routine engineering rather than firefighting when the process is the same every time.

Contact

Let’s connect

Have a Liferay or Backend project you’d like to talk through? Fill in the form and I’ll get back to you.

Book Calendar