Isomerizer Posted February 21, 2013 Share Posted February 21, 2013 I am trying to develop a basic PHP tool to record the response times of a website, when using HTTP and HTTPS. Overall, I wish to record several times and then compare them. To give an overview of the difference of speed between HTTP & HTTPS. I am using CURL, I have made this so far: <?php // curl handle $ch = curl_init($_GET['x']); // ?x= url target curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1); // fresh connection, don't cache curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1); curl_setopt($ch, CURLOPT_CERTINFO, 1); // enables SSL ? // execute / load website curl_exec($ch); // check for error if(!curl_errno($ch)) { $c = curl_getinfo($ch); echo 'Sending request to: ' . $c['url'].' <br /> Connect time: '.$c['connect_time'].'<br /> Name Lookup time: '.$c['namelookup_time'].'<br /> Pre transfer time: '.$c['pretransfer_time'].'<br /> Header size: '.$c['header_size'].'<br /> Average download speed: '.$c['speed_download'].'<br /> Took <b>'.$c['total_time'].'</b> seconds in total'; } // close curl curl_close($ch); ?> Does anyone know if CURL does indeed take into account the HTTPS headers and additional procedures it completes (e.g. handshake phase) when establishing a connection? I think I have set the CURL options correctly, I have ran several tests, they seem to differ. But I need to know if CURL is accurate for this sort of testing, or would you recommend something else? HTTP: http://www.isomerizer.com/curl.php?x=http://www.google.com HTTPS: http://www.isomerizer.com/curl.php?x=https://www.google.com Also, would my webserver hosting the PHP make a difference? Quote Link to comment Share on other sites More sharing options...
a_bertrand Posted February 21, 2013 Share Posted February 21, 2013 I don't fully remember how HTTPS is implemented, so I can't really answer you with full details, but as far as I remember SSL with public and private key, the first exchange is made using those keys: Client sends a bidirectional random key to communicate afterward to the server, encrypted with the public key of the server. Further communication between the 2 is made via the symmetrical key, because it's faster. So if HTTPS is the same (and if I remember right it is), that should mean that the first HTTPS call you do should be slower and then faster. Therefore what do you want to test? The first communication or communication in general? Also I don't know how CURL is implemented, don't know if it cache something, and how the implementation is done. Too many unknown pieces on my side. Finally as any benchmark, you will see many different timing, depending on your HTTP & HTTPS server as well as your client testing. So if you want to have a clean setup just to test the HTTP & HTTPS speed difference, build 2 computers on a network without anything else attached. And run your test many many times, to average the data. Quote Link to comment Share on other sites More sharing options...
Spudinski Posted February 21, 2013 Share Posted February 21, 2013 See: http://www.semicomplete.com/blog/geekery/ssl-latency.html Quote Link to comment Share on other sites More sharing options...
Isomerizer Posted February 23, 2013 Author Share Posted February 23, 2013 See: http://www.semicomplete.com/blog/geekery/ssl-latency.html Thanks Spud, an interesting read and some good testing. I'll use this within my research. :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.