How can I store application-level statistics on the fly in an application under Apache?

I have an application running under apache that I want to save at the time of "statistics". I want the application to tell me the following:

  • queries per second, broken down by query type
  • latency in order to make requests to various backend services through savings (by service and server).
  • number of errors serviced per second
  • and etc.

I want to do this without any external dependencies. However, I am encountering problems exchanging statistics between apache processes. Obviously, I cannot just use global memory. What is a good template for this kind of problem?

The application is written in python using pylons, although I suspect that this is more of a “process-through-communication” design issue than what is specific to python.

+3
source share
3 answers

Perhaps you could save the appropriate counters and other statistics in memcached, which all apache processes access?

+1
source

I want to do this without any external dependencies.

What if your apache somehow dies? (Separation of problems?)

() Nagios , , . , / " / ", "cpu load/user activy X per second" .. , .

nagios , .

Apache

apache, apache mod_status nagios.

:

APACHE OK - 0.080 sec. response time, Busy/Idle 18/16, open 766/800, ReqPerSec 12.4, BytesPerReq 3074, BytesPerSec 38034

mod_status , .

Nagios, nagios - , nagios ( script)..

:

Memcache:
OK - consumption: 82.88% (106.1 MBytes/128.0 MBytes), connections: 2, requests/s: 10.99, hitrate: 95.2% (34601210/36346999), getrate: 50.1% (36346999/72542987)

Application feature #1 usage:
OK - last 5m: 22 last 24h: 655 ever: 26121

Application feature #2 usage:
OK - last 5m: 39 last 24h: 11011

Other applications metrics:
OK - users online: 556

: Nagios . , 3-4 , , , .

Nagios

+1

pylons.g. Globals lib/app_globals.py Pylons. , .

/app_globals.py:

class Globals(object):
    def __init__(self):
        self.requests_served = 0

/status.py:

from pylons import g

class StatusController(BaseController):
    def status(self):
        g.requests_served += 1
        return "Served %d requests." % g.requests_served
-1

Source: https://habr.com/ru/post/1729466/


All Articles