openapi yaml reloads slow performance

17 views
Skip to first unread message

martha alvarez

unread,
Sep 1, 2021, 5:24:28 PM9/1/21
to modwsgi
I am a newbie at using mod_wsgi. I was able to get it working using my swagger py module (to replace the dev flask server) , but every time the .wsgi file runs it causes the add.api yaml files to reload which take 3 secs since it re-launches my py file for each api call.  This seems like a lot of overhead per call. How can I preload these yaml files to avoid this overheard?  I cannot seem to find an example of what I am trying to do.  Everything is working except this overhead will affect performance when processing many rest api requests.  When I used to just run it as w/the dev FLASK server via app.run, I ran it as a daemon process in the background and it only loaded the yaml files on start up and I proxied calls to the specified port so I didn't see this repetitive overhead.
    
WSGIDaemonProcess mytest user=apache group=apache display-name=me-mytest processes=5
    WSGIScriptAlias /mytest /xxx/bin/mytest.wsgi process-group=mytest
    <Directory "/xxx/bin">
        WSGIProcessGroup mytest
        WSGIApplicationGroup %{GLOBAL}
        Require all granted
    </Directory>

mytest.wsgi
#!/usr/bin/env python3
from mytest import app as application

mytest.py
 def app(environ, start_response):
    ...
   app = connexion.App(__name__, specification_dir='./')
   app.add_api(...)
   app.add_api(...). ----> TAKING 3 seconds overall for each request being processed
    if __name__ == '__main__':
       app.run(host=xyz, port = 123) -> Runs dev FLASK server - generally run in background as daemon process
    else:
      return app(environ, start_response) -> Runs via mod_wsgi 

Reply all
Reply to author
Forward
0 new messages