473,604 Members | 2,483 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Python to measure HTTP and HTTPS performances: best way ???

I want to write a script that will monitore the performance of a web
application delivering HTTP and HTTPS pages.

I would like to know the best way to do it...

By reading Python Doc. I've found the following:
For HTTP:
def http_monitor(ho st,url):
starttts=time.t ime()
conn=httplib.HT TPConnection(ho st)
conn.request("g et","/%s" % url)
res=conn.getres ponse()
data=res.read()
return time.time()-starttts
Where Host and URL concerns an HTTP web page.

For HTTPS:
def https_monitor(h ost,url):
starttts=time.t ime()
conn=httplib.HT TPSConnection(h ost)
conn.request("g et","/%s" % url)
res=conn.getres ponse()
data=res.read()
return time.time()-starttts
Where Host and URL concerns an HTTPS web page.

Does this is valid ?
For HTTPS, I'm not dealing with encryption Key ... is it normal ?

Thanks.
Jul 18 '05 #1
2 2716
HTTPS is usually about 5x slower than HTTP on the exact same web server
because of the encryption.
Best to send a mid-sized JPG or PNG and time that.

Jul 18 '05 #2
Am Fri, 12 Nov 2004 02:40:13 -0800 schrieb vincent delft:
I want to write a script that will monitore the performance of a web
application delivering HTTP and HTTPS pages.

I would like to know the best way to do it...


Hi,

I did the same some days ago. Here is my code:
#!/usr/bin/env python
# -*- coding: iso-8859-1 -*-
# Python Imports
import os
import sys
import time
import base64
import signal
import urllib2

MAX_PROCESSES=4 0

URL="https://yourserver/....?var=foo... "

# HTTP Basic Auth
USER="..."
PASSWORD="..."

def usage():
print """Usage: %s
StressTest ...
""" % (os.path.basena me(sys.argv[0]))

def mache_stress():
dauer_list=[]
try:
while 1:
request=urllib2 .Request(URL)
base64string=ba se64.encodestri ng('%s:%s' % (
USER, PASSWORD))
request.add_hea der("Authorizat ion", "Basic %s" % base64string)
start=time.time ()
fd=urllib2.urlo pen(request)
fd.read()
dauer=time.time ()-start
print "%s OK %05.2f" % (os.getpid(),
dauer)
dauer_list.appe nd(dauer)
except KeyboardInterru pt:
if dauer_list:
all=0
for d in dauer_list:
all+=d
print "Ende %s %s Requests %05.2f avg." % (
os.getpid(), len(dauer_list) , all/len(dauer_list) )
raise

def main():
if len(sys.argv)!= 1:
usage()
sys.exit(1)

pids=[]
try:
print "Mit CTRL-C beenden."
print "URL:", URL
print "Anzahl der Prozesse:", MAX_PROCESSES
for i in range(MAX_PROCE SSES):
pid=os.fork()
if not pid:
# Hier ist das Kind
mache_stress()
else:
pids.append(pid )
os.waitpid(0, 0)
except KeyboardInterru pt:
#for pid in pids:
# os.kill(pid, signal.SIGINT)
pass

if __name__=="__ma in__":
main()

Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3037
by: lebo | last post by:
Hi I'm trying to understand how Python handles memory usage and dynamic object loading and unloading. Problem to solve? Build a very low memory footprint (non-GUI) Python application for Unix/Windows. Why use Python? End user flexibility. So far it seems that (on Windows): (1) memory increases when you import <module>. Expected behaviour. (2) memory does not release when you del <module>. Why not? Is Python
14
2644
by: 2mc | last post by:
Generally speaking, if one had a list (from regular Python) and an array (from Numerical Python) that contained the same number of elements, would a While loop or a For loop process them at the same speed? Or, would the array process faster? I'm new to Python, so my question may expose my ignorance. I appreciate anyone's effort to help me understand. Thanks. It is much appreciated.
14
2843
by: David MacQuigg | last post by:
I am starting a new thread so we can avoid some of the non-productive argument following my earlier post "What is good about Prothon". At Mr. Hahn's request, I will avoid using the name "Prothon" in the subject of any post to this newsgroup. Please ignore the old thread. I've also updated my webpage http://ece.arizona.edu/~edatools/Python Anyone with some good ideas for "Python 3" is welcome to contribute. I hope GvR won't sue me for...
7
3649
by: Irmen de Jong | last post by:
Hi, Things like Twisted, medusa, etc.... that claim to be able to support hundreds of concurrent connections because of the async I/O framework they're based on.... can someone give a few examples of some web sites actually using those Python frameworks? Thanks :) --Irmen
25
5728
by: abhinav | last post by:
Hello guys, I am a novice in python.I have to implement a full fledged mail server ..But i am not able to choose the language.Should i go for C(socket API) or python for this project? What are the advantages of one over the other in implementing this server.which language will be easier? What are the performance issues?In what language are mail servers generally written?
9
2768
by: James Stroud | last post by:
Hello All, I have been trying to make an https client with python, but it seems that, to do this, one needs to have the socket module compiled with ssl. This is not the default. So I have a couple of questions. 1. Where do I specify to compile socket with ssl? I found no obvious option in configure or setup.py or several other files I checked. 2. Is there a way to do this without re-compiling all of python?
53
5201
by: Vicent Giner | last post by:
Hello. I am new to Python. It seems a very interesting language to me. Its simplicity is very attractive. However, it is usually said that Python is not a compiled but interpreted programming language —I mean, it is not like C, in that sense. I am working on my PhD Thesis, which is about Operations Research,
0
7929
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8419
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8409
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8065
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
5882
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3907
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3955
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2434
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1526
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.