Re: Cherrypy latency with long cookie values
Petros <[email protected]> Tue, 27 Feb 2018 00:36:56 -0800 (PST)
| Newsgroups | gmane.comp.python.cherrypy |
|---|---|
| Message-ID | <[email protected]> |
Hi Michiel, Yes, please find attached a server using bottlepy and a script for firing multiple requests. You can try to use longer cookies to see how the response time increases and how this is not observed using one of the other servers, paste or waitress. Thanks. On Sunday, February 25, 2018 at 11:10:49 AM UTC+2, Michiel Overtoom wrote: > > > Hi, > > > On 2018-02-23, at 15:17, Petros <[email protected] <javascript:>> > wrote: > > > > I noticed that when I fire multiple requests from a script, there is an > increasing latency in the response times BUT this only happens when I pass > a 348 chars long cookie. With shorted cookie value or no cookies latency is > decreasing. Any idea what maybe the problem? > > Do you have a minimal example app (and driver script) which demonstrates > this problem? I'd like to reproduce it. > > Greetings, > > -- > There are two hard things in computer science: cache invalidation, naming > things, and off-by-one errors." - Jeff Atwood > > -- You received this message because you are subscribed to the Google Groups "cherrypy-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to cherrypy-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected] To post to this group, send email to cherrypy-users-/JYPxA39Uh5TLH3MbocFF+G/[email protected] Visit this group at https://groups.google.com/group/cherrypy-users. For more options, visit https://groups.google.com/d/optout.
server_bottle.py
(text/x-python, 267 B)
#!/usr/bin/env python
from bottle import Bottle, run, route
import time
app = Bottle()
@app.route('/hello')
def hello():
print "Test"
#time.sleep(5)
@app.route('/hello2')
def hello2():
time.sleep(5)
run(app, host='0.0.0.0', server="cherrypy", port=4301)
multiple_reqs_thread.py
(text/x-python, 1.3 KB)
#!/usr/bin/python
import requests
import time
from threading import Thread
import sys
SESSION_COOKIE_NAME = "test.cookie"
num_threads =sys.argv[1]
if not num_threads:
raise RuntimeError("Number of threads not specified!")
url = "http://127.0.0.1:4301/hello"
cookies = dict()
cookies[SESSION_COOKIE_NAME] = '079f85233733f1f5c1f0339b1d941297b2883b40gAJ9cQEoVQNfaWRxAlUgODU0OGMxZWU5ZWUyNGUyNzk5OGIwYjg5ZDc5ZmJlYzJxA1UHdXNlcl9pZHEEVSBiMmJlNDE5MDgxYmIxMWU3OGM4NjJjNjAwYzM2NTQyZXEFVQ5fY3JlYXRpb25fdGltZXEGR0HWpAtASTdMVRFjdXJyZW50X3RlbmFudF9pZHEHVSBiMmJkNTczMDgxYmIxMWU3ODEwNzJjNjAwYzM2NTQyZXEIVQ5fYWNjZXNzZWRfdGltZXEJR0HWpAuJJcKPVQ5hY3R1YWxfdXNlcl9pZHEKaAV1Lg=='
total_time = 0
def make_request(id):
start = time.time()
#print start
r = requests.get(url, headers={'accept': 'text/html'}, cookies=cookies)
print r
end = time.time()
#print "--",end
print 'Thread {0} takes {1} seconds to finish with status code {2}'.format(id, end - start, r.status_code)
global total_time
total_time = total_time + (end - start)
def start(num):
ts = []
for i in range(num):
t = Thread(target=make_request, args=(i,))
ts.append(t)
for t in ts: t.start()
for t in ts: t.join()
global total_time
print "\n\nAverage Time", total_time / int(num_threads)
start(int(num_threads))