473,796 Members | 2,550 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 2725
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
3049
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
2657
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
2868
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
3664
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
5770
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
2776
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
5260
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
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9531
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
10237
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
10187
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,...
0
10018
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9055
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6795
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5446
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...
3
2928
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.