1

I've Ubuntu 14.04.5 LTS (i686) on a Digital Ocean droplet with 2x2.4GHzCPU & 4gb physical memory. I am running a web2py application on it with Apache and mod_wsgi. There are a few additional python modules installed on the box, like numpy and opencv2. The database is MySQL 5.5.

A Wordpress website on another server calls this web2py application using php-curl. Usually the response time is 2-5 seconds. But occasionally it timeouts (response time goes to >1000 seconds). I've added logging points in the Web2py application and they tell that after reaching the application, everything completes in 2-3 seconds. But in Apache2 access log, response time logged as a number higher than 1000 seconds. In the access log, the request time is approximately the same when request is initiated from the Wordpress website.

Can anyone point out how to find-out the reason of this intermittent slow response?

Thanks

2
  • Have you added logging of timestamp right into the beginning and end of your web2py application? Sep 17, 2017 at 18:40
  • Yes, I did it initially in the controller, the controller function and the main model file but it didn't help revealing the root cause. But finally I found that the developer left a db connection statement in the default model file. This was for a remote database, was not being used in the application and causing the slow response. Sep 18, 2017 at 6:30

2 Answers 2

0

In order to discover the root cause of the timeout, you could use php slowlog, which will explain which function is responsible.

You have to modify your www.conf and change the 0 default value of the option request_slowlog_timeout. For example :

request_slowlog_timeout = 10s

You can read a little more about activating slowlog here, and take a look on some common sources of slowness here.

1
  • The slow response is from apache+mod_wsgi which is serving a python based application and has nothing to do with php. php-curl is being used here on client-side. Are you suggesting to do this modification on the server running wordpress website and acting as a client for the python-application? Thanks Sep 16, 2017 at 3:54
0

Finally I've been able to find out the cause of the problem. It was a connection statement to a remote database in the default model file of the web2py application. This database connection was not being used in the application anywhere. But since it was in a model file, whenever a controller function is called the application tries to unnecessarily connect to that remote database.

Initially I added logging points everywhere in the application but didn't add in the default model file of the application; Therefore logs were silent about the root cause. Then I tested the application by just replacing the application folder contents one by one with the files of a demo application (which comes with web2py) and helped revealing the root cause of the problem. The root cause was then verified by adding the logging at the start and end of the default model files of the application.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .