Expand my Community achievements bar.

SOLVED

503 - Timeout error

Avatar

Level 2

I am getting 503 timeout error in my AEM application. The application is getting data from an external system through an AEM servlet and that data is being rendered in UI. The application gets time out if the response time is more than 30 seconds. Is there any specific configuration which is responsible for this timeout. 

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

Hi,

 

Every AEM function which reaches out to an external system should be guarded by a timeout, and in most cases a timeout of more than 30 seconds is inadequate and too high; what's the functionality on the other system which takes 30 seconds to response properly?

 

This gets even more important, if an user makes a request to AEM and AEM in turn makes a request to a different system. The AEM standard timeout is 30 second (which is quite high for an interactive application), so the application on the other system should also respond very quickly, thus a timeout of say 5 seconds is appropriate. Relying on default timeouts is a good way to run a Denial of Service attack against AEM, because if all threads are blocked (waiting on the external system which response very slowly) your AEM doesn't have free threads anymore to handle legitimate requests (which do not require to reach this other system and which could be handled within milliseconds).

 

So: Do not increase the timeout on AEM side, but rather build your application in a more resilient way.

 

Ok, understood. But that means that you reconfigure AEM explicitly for this request.

 

The timeout configuration is a safety measure of every system, which allows it to recover from operations which take too long. If you increase the overall timeout, the loosen this safety net a bit.

In your case you have 2 timeouts to consider:

* The timeout of jetty (the request from user to AEM)

* the timeout of your external request (from AEM to the external system)

 

You have to increase the timeout of both.

View solution in original post

8 Replies

Avatar

Community Advisor

I think you should check the response from external application as well. Could be issue at external point as well.

You can try though -

Apache Felix Jetty Based HTTP Service

Connection Timeout
Time limit for reaching an timeout specified in milliseconds. This property applies to both HTTP and HTTP connections. Defaults to 60 seconds. (org.apache.felix.http.timeout)


Arun Patidar

Avatar

Level 2
Thanks Arun for looking into this, I tried changing this configuration but it did not help.

Avatar

Correct answer by
Employee Advisor

Hi,

 

Every AEM function which reaches out to an external system should be guarded by a timeout, and in most cases a timeout of more than 30 seconds is inadequate and too high; what's the functionality on the other system which takes 30 seconds to response properly?

 

This gets even more important, if an user makes a request to AEM and AEM in turn makes a request to a different system. The AEM standard timeout is 30 second (which is quite high for an interactive application), so the application on the other system should also respond very quickly, thus a timeout of say 5 seconds is appropriate. Relying on default timeouts is a good way to run a Denial of Service attack against AEM, because if all threads are blocked (waiting on the external system which response very slowly) your AEM doesn't have free threads anymore to handle legitimate requests (which do not require to reach this other system and which could be handled within milliseconds).

 

So: Do not increase the timeout on AEM side, but rather build your application in a more resilient way.

 

Ok, understood. But that means that you reconfigure AEM explicitly for this request.

 

The timeout configuration is a safety measure of every system, which allows it to recover from operations which take too long. If you increase the overall timeout, the loosen this safety net a bit.

In your case you have 2 timeouts to consider:

* The timeout of jetty (the request from user to AEM)

* the timeout of your external request (from AEM to the external system)

 

You have to increase the timeout of both.

Avatar

Level 2
Thanks for your response. The application is quite efficient and usually gets response is few milliseconds but we have a module which runs a report for the period of 2 - 3 years and runs a complex query over millions of DB records so this type of delayed response is expected from users perceptive. Usually the AEM logs records the response time around 45 seconds for the long running reports but the network console shows 503 timeout error. I only need slight increase in the timeout to cope up with this scenario.

Avatar

Employee Advisor

Ok, understood. But that means that you reconfigure AEM explicitly for this request.

 

The timeout configuration is a safety measure of every system, which allows it to recover from operations which take too long. If you increase the overall timeout, the loosen this safety net a bit.

In your case you have 2 timeouts to consider:

* The timeout of jetty (the request from user to AEM)

* the timeout of your external request (from AEM to the external system)

 

You have to increase the timeout of both.

Avatar

Level 8

I just want to highlight a few things

Taking 30second's time is not a good sign, if you are testing this on a lower environment then I feel it is ok to wait for 30 seconds for a response, but if you want to deploy this to the production with the same configuration then it is going to be a problem the end-user will get frustrated and also it is not good user experience.

Check with the people who are managing the external system and get the SLA's, if the external system always behaves like that I mean takes more than 30 seconds then don't rely on that you need to change your approach.

You can write a scheduler which fetches data from the external system and stores in the AEM repository, the component which you want to display external content will read it from your AEM repository. 

With this, you will get the best user experience and you do not need to wait for on an external system especially when it is not reliable.

 

 

Avatar

Level 2
Thanks for your response. The application is quite efficient and usually gets response is few milliseconds but we have a module which runs a report for the period of 2 - 3 years and runs a complex query over millions of DB records so this type of delayed response is expected from users perceptive.