Too Many CPU Intensive Tasks: A Common Performance Issue in DXP 7.0

This article documents a common performance issue related to running Too Many CPU Intensive Tasks within Liferay DXP 7.0. Continue reading to discover the necessary information about this issue and how to navigate through it. 

The following are some of the more common causes and solutions:

  1. Minifier
  2. StripFilter
  3. GZipFilter
  4. Password Hashing


Some subscribers may encounter a performance issue when many CPU intensive tasks are running at the same time. This is a generalized pattern that could come from a variety of use cases. Depending on the severity of the issue being faced, the thread dump may contain anywhere from tens to hundreds of threads working on such tasks. Customers will see higher CPU usage and slower response times, and in rare cases, the Liferay platform will become seemingly unresponsive. 

Please review the following information regarding the more common causes, and the subsequent solutions. 


The Minifier will attempt to minify CSS and Javascript resources before sending them to the browser. This action will save network bandwidth as it will result in smaller files. However, it entails a performance penalty on the CPU.

Minifier is enabled by default but can be turned off by setting the below property in the minifier.enabled=false.

In a thread dump, we would notice this issue if we were seeing the following string dozens, or in some cases, hundreds of times:


"http-/" daemon prio=10 tid=0x00007f8bfc282ea0 nid=0x2c0d runnable [0x00007f8aa6d27000]
   java.lang.Thread.State: RUNNABLE
    at java.util.regex.Pattern$CharProperty$1.isSatisfiedBy(
    at java.util.regex.Pattern$7.isSatisfiedBy(
    at java.util.regex.Pattern$7.isSatisfiedBy(
    at java.util.regex.Pattern$7.isSatisfiedBy(
    at java.util.regex.Pattern$CharProperty.match(
    at java.util.regex.Pattern$Curly.match0(
    at java.util.regex.Pattern$Curly.match(
    at java.util.regex.Pattern$Start.match(
    at java.util.regex.Matcher.find(
    at java.util.regex.Matcher.replaceAll(
    at java.lang.String.replaceAll(
    at com.liferay.portal.util.MinifierUtil._minifyCss(
    at com.liferay.portal.util.MinifierUtil.minifyCss(

Here is another occurrence from the same thread dump using Spotify's Online Thread Dump Analyzer:

In such cases, notice that the exact stacktrace may be different. Since all these threads are executing, they are at different stages of their lives: all of them waiting for CPU time to be able to progress which leads to resource starvation.

The solution to this is to evaluate whether CSS and Javascript minification is needed. If minification is necessary, then further resources may be needed. Subscribers should consider clustering the platform use or use additional resources by caching by web servers or offloading static content to CDN servers. If minification is not needed, then simply turning it off via the aforementioned minifier.enabled property should ease the stress on the on the CPU.


The StripFilter is similar to the Minifier in that the end result is smaller files in exchange for CPU usage. See the comment for Liferay Portal 6.2: The strip filter will remove blank lines from the outputted content. This will speed up page rendering for users that are on dial up.

We recommend turning this off from the start because there is no real benefit compared to the cost on the CPU. Removing new lines from the response should save some space. However, gzipping the content is very efficient and it does not really matter whether there is newlines in a file or not (except in extreme edge cases). Furthermore, the time it takes for the browser to load a page is only affected minutely; the majority of time taken to load a page is spent waiting on resources to be downloaded anyway.

This means that there is no benefit of doing this for the network nor for the end user and yet it has performance impact on the CPU.

To find such threads, just search for the string StripFilter.strip. - If there are more than five occurrences in any given thread dumps, be aware that your response time is suffering because of this. Included below the top of a stack trace that is actually executing the StripFilter:

"http-/" daemon prio=10 tid=0x00007f796c343250 nid=0x175e runnable [0x00007f7854134000]
   java.lang.Thread.State: RUNNABLE
    at java.nio.Buffer.checkIndex(
    at java.nio.CharBuffer.charAt(
    at com.liferay.portal.servlet.filters.strip.StripFilter.processInput(
    at com.liferay.portal.servlet.filters.strip.StripFilter.strip(
    at com.liferay.portal.servlet.filters.strip.StripFilter.processFilter(


The GZipFilter's job is to compress the response going back to the browser to save on bandwidth and, ultimately, page load times. It is controlled by the below property:

The GZipFilter was introduced earlier when discussing the StripFilter's impact; in that section, it was stated that having the StripFilter enabled is not needed because the gzipping the response is more beneficial anyway. The choice of the word gzipping instead of GZipFilter is intentional; if at all possible, Liferay recommends alternative ways of gzipping the content. For example, Apache's mod_deflate has the benefit of being on another box which allows another server's CPU work on compressing the response. The GZipFilter is hard to catch as its main job is to compress everything once the response is ready. Therefore, the execution process is visible by seeing GZip related Java classes executing at the end and a GZipResponse$1 object being locked, for example:

"http-/" daemon prio=10 tid=0x00007f8bfc26f460 nid=0x2c01 runnable [0x00007f8aa7933000]
   java.lang.Thread.State: RUNNABLE
    at Method)
    - locked <0x00000006dd9bf380> (a
    - locked <0x00000006dd9bf2f8> (a com.liferay.portal.servlet.filters.gzip.GZipResponse$1)
    at com.liferay.portal.kernel.servlet.ServletOutputStreamAdapter.write(

As mentioned, our recommendation is turning the GZipFilter off and relying on other services if possible, even if there are currently no performance issues caused by or related to GZipFilter. 

Password Hashing

Comparing passwords is done by hashing the password that the user specified in the form, then comparing it with the already hashed (and saved) password in the database. By default, the Liferay platform uses a computational heavy algorithm: PBKDF2 with HMAC SHA1 with 160 bit hashes and 128,000 rounds.

Below is the portal property that sets the encryption algorithm:

The reason it has such a toll on the CPU is because of the way it works. It uses a pseudo-random function on the input text plus a salt to create -bit hashes (default: 160), then repeats it times (default: 128,000). As a result, many users logging in at the same time could potentially lock up the portal for a while until the CPU can handle all the requests. Below is the top of a stack trace from a thread working on a user login:

"ajp--" daemon prio=10 tid=0x00007fcef1575600 nid=0xfe4d runnable [0x00007fced4138000]
   java.lang.Thread.State: RUNNABLE
    at com.sun.crypto.provider.HmacSHA1.engineReset(
    at javax.crypto.Mac.doFinal(
    at javax.crypto.Mac.doFinal(
    at com.sun.crypto.provider.PBKDF2KeyImpl.deriveKey(
    at com.sun.crypto.provider.PBKDF2KeyImpl.(
    at com.sun.crypto.provider.PBKDF2HmacSHA1Factory.engineGenerateSecret(
    at javax.crypto.SecretKeyFactory.generateSecret(

Seeing multiple threads, like this one, working on encrypting the password is an indication that the Liferay platform is suffering and users will report (or have already reported) long wait times when they are trying to log in.

There are a few solutions to this issue.

  1. Tuning the PBKDF2algorithm:
    1. Either lower the size of the hash that is generated or the number of rounds.
    2. Both of these steps, however, lower the strength of the password encryption which needs to be taken into consideration as well.
    3. User passwords may need to be forcibly reset.
  2. Using another algorithm altogether:
    1. Moving from PBKDF2 to another less computational heavy algorithm would also ease the impact on the CPU.
    2. This also has the downside of moving to a less secure encryption.
    3. User passwords may need to be forcibly reset.
  3. Using a third party authentication service like LDAP or SSO solutions.
    1. The process of authentication is offloaded and the Liferay platform simply takes care of negotiating with the third party services by sending credentials, managing sessions, etc. 
2 人中有 2 人觉得有帮助