paint-brush
A Simple CDN Speed Test Script in Python by@productivityhacks
547 reads
547 reads

A Simple CDN Speed Test Script in Python

tldt arrow

Too Long; Didn't Read

There is a simple python script I use to speed test CDNs. It’s open-sourced under the MIT license. The repository is: //://github.com/speedtestdemon/speed-tests and the python script is “test.py” The script takes a single input “URL” and tests cold cache, hot cache, cold cache and warm cache. The response headers are important to see the header that reports ‘Hit’, ‘Miss’ or ‘RefreshHit”

People Mentioned

Mention Thumbnail

Coin Mentioned

Mention Thumbnail
featured image - A Simple CDN Speed Test Script in Python
Productivity Hacks & Software Performance Analysis HackerNoon profile picture
Here is a simple python script I use to speed test CDNs. It’s open-sourced under the MIT license.


The repository is: and the python script is “”.


The script takes a single input “URL”. Example usage: `python3 `.


Here are the script outputs:


  1. Cold cache, hot cache, and warm cache tests (in that order).
  2. The response headers for cold cache and warm cache tests. This is important to see the header that reports “Hit”, “Miss”, or “RefreshHit”. It ensures that you’re running the cold cache and warm cache tests correctly.
  3. The hot cache times are averages of 10 curls.


Here is an example output of the python script:
\-------------------------------------------------------------  
Testing "Cold cache speed"  
\-------------------------------------------------------------  
Got headers:  
HTTP/2 200  
content-type: image/png  
content-length: 719983  
date: Fri, 25 Jun 2021 15:01:17 GMT  
last-modified: Mon, 07 Jun 2021 00:16:21 GMT  
etag: "52ae2ff2354d4a68e680b77b4da58985"  
accept-ranges: bytes  
server: AmazonS3  
x-cache: Miss from cloudfront  
via: 1.1 9e8d1ff1eee770054f1561535ab320b2.cloudfront.net (CloudFront)  
x-amz-cf-pop: DFW55-C3  
x-amz-cf-id: lQPqV7PnAuwl\_52kDXS2rsC20kSrloThTOG8cN1fK-MHUce0NNIDIA==time\_namelookup: 0.000000304  
time\_connect: 0.029998560  
time\_appconnect: 0.066801027  
time\_pretransfer: 0.000200673  
time\_redirect: 0.00000000000000000000  
time\_starttransfer: 1.02790999999999987935  
time to download: 1.068002463  
time\_total: 2.309002063  
\-------------------------------------------------------------  
Testing "Hot cache speed"  
\-------------------------------------------------------------  
10 requests done. Average:  
time\_namelookup: 0.000000036  
time\_connect: 0.02068409999999999693  
time\_appconnect: 0.060000270  
time\_pretransfer: 0.00024639999999999802  
time\_redirect: 0.00000000000000000000  
time\_starttransfer: 0.034999767  
time to download: 0.200000608  
time\_total: 0.339998609  
\-------------------------------------------------------------  
Testing "Warm cache speed"  
\-------------------------------------------------------------  
Sleeping for 0.5 hr to move cache from hot to warm  
Got headers:  
HTTP/2 200  
content-type: image/png  
content-length: 719983  
date: Fri, 25 Jun 2021 15:01:17 GMT  
last-modified: Mon, 07 Jun 2021 00:16:21 GMT  
etag: "52ae2ff2354d4a68e680b77b4da58985"  
accept-ranges: bytes  
server: AmazonS3  
x-cache: Hit from cloudfront  
via: 1.1 7c556a1545ad08a01c9e86ad41ac73a1.cloudfront.net (CloudFront)  
x-amz-cf-pop: DFW55-C3  
x-amz-cf-id: ACpfQ14wbO\_vjjAisApBAJkRphZQ7IbD4Lawc77eo\_K5UM\_3-yWPZw==  
age: 1804time\_namelookup: 0.05657399999999999929  
time\_connect: 0.024000743  
time\_appconnect: 0.07374400000000000399  
time\_pretransfer: 0.009998208  
time\_redirect: 0.00000000000000000000  
time\_starttransfer: 0.029299398  
time to download: 0.22752000000000000002  
time\_total: 0.499998678
Also published on .
바카라사이트 바카라사이트 온라인바카라