0

I am having a strange issue in production cloud servers.

I have a server java method (REST service method) which have logs in first and last line of method.

The issue is that the method call in access logs shows 10 times more delay than the time difference as present in tomcat logs.

For instance tomcat logs shows method executed in 1 seconds while access log shows 13+ seconds. The same delay is observed in network tab of browser.

Is there any way to understand the delay? I checked the server disk status and it shows 20 to 30% usage. The memory usage reached 80% max and CPU is also fine.

What can be the reason for the intermittent delay as per access logs?

Amit Mahajan
  • 895
  • 6
  • 34

1 Answers1

0

Access logs are pushed in chunk to log files by tomcat servers. They are not logged as the requests are served. Tomcat does this to minimize File I/O.

Where as normal logs are written to log files as you log them.

kk.
  • 3,747
  • 12
  • 36
  • 67
  • This doesn't answer the question, if method execution completed why access log is showing delay? (although access log is written later but the time component of log is different than tomcat log time delay) – Amit Mahajan Jun 22 '17 at 15:37
  • @amitmah: This is the answer to the question mate. This is the behaviour of tomcat. It buffers the access logs and pushes them to log file only after buffer is full https://stackoverflow.com/questions/31109090/tomcat-http-access-log-has-a-delay-in-writing-to-the-file – kk. Jun 22 '17 at 15:39
  • Whatever pattern you specify it does not matter. Tomcat has this behaviour by default. You can modify these settings by following the instructions in the above URL (mentioned in one of my above comment) – kk. Jun 22 '17 at 16:17
  • Yeah it should be `5000` as per your explanation. – kk. Jun 22 '17 at 16:20
  • No it is not, as per the logs i see 13000 in access logs and SS component from tomcat-log file shows 1 second delay – Amit Mahajan Jun 22 '17 at 16:20
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/147395/discussion-between-amitmah-and-krishna-kuntala). – Amit Mahajan Jun 22 '17 at 16:21