Re: [cherrypy-users] Cherrypy as production wsgi server

343 views
Skip to first unread message

Sylvain Hellegouarch

unread,
Nov 10, 2012, 3:58:12 AM11/10/12
to cherryp...@googlegroups.com
Javier,

On Fri, Nov 9, 2012 at 11:59 PM, Jeffrey Melloy <jme...@gmail.com> wrote:
I'm running Cherrypy as the wsgi server in front of a flask app. How do I start getting statistics about increasing the threading count?  It serves a lot of images that are called simultaneously from a dashboard.

from cherrypy import wsgiserver, log, _cplogging
from test_qd_web_service import app

import logging
import logging.handlers
import sys

from paste.translogger import TransLogger
from repoze.profile.profiler import AccumulatingProfileMiddleware


def run():

    logger = logging.getLogger("accesslog")
    acc = logging.handlers.TimedRotatingFileHandler("test.access.log", when="midnight", backupCount = 7)
    logger.addHandler(acc)
    
    wsgi_app = TransLogger(app, logger_name="accesslog", setup_console_handler=False)

    profiled_app = AccumulatingProfileMiddleware(
        wsgi_app,
        log_filename='ws.profile',
        discard_first_request=True,
        flush_at_shutdown=True,
        path='/_profile'
        )

    d = wsgiserver.WSGIPathInfoDispatcher({'/': wsgi_app})
    
    server = wsgiserver.CherryPyWSGIServer(('0.0.0.0', 5050), wsgi_app, numthreads=25)
    

    try:    
        server.start()
    except KeyboardInterrupt:
        server.stop()
                
if __name__ == '__main__':
    run()



I cannot comment on your code but there is a rather undocumented feature in CherryPy 3.2.2 which allows to gather statistics of the server usage.

See that page:

--
- Sylvain
http://www.defuze.org
http://twitter.com/lawouach
Reply all
Reply to author
Forward
0 new messages