I will have to respectfully disagree with you BrowserUk. Delays when using SSL/TLS with modern hardware are hardly noticeable nowadays. Your network latency would have to be incredibly low in order for the decryption to take longer than fetching the data. The idea I had is that the single processor could be decrypting data while it is waiting for data from the network, by using an event framework. As long as network latency is greater, hopefully much greater, than the amount of time decryption takes, performance should not suffer.

From my own experimenting, a prohibitive delay when using HTTPS comes from the handshake that begins the encrypted connection. The client and server exchange messages back and forth, each subject to network latency! Taking advantage of persistent HTTP 1.1 connections is practically a necessity.

I made a benchmark to check my theory. The script is admittedly funky and limited. The experiment uses EV, AnyEvent, and AnyEvent::HTTP to see if CPU would be a limited factor, based upon the idea that switching between http and https would show noticeable differences. Relearning AnyEvent took me awhile and I wasted alot of time on this today but maybe someone will find it useful for stress-testing or experimenting.

edit: Cleaned up the code to play around with it more.

#!/usr/bin/env perl ## # webstress.pl -- Website stress-testing with AnyEvent. use warnings ('FATAL' => 'all'); use strict; use EV; use AnyEvent; use AnyEvent::HTTP; use Getopt::Long; sub usage { die "Usage:\t$0 [--conmax 5] [--reqs 100] [--desist] <url>\n" unless @ARGV == 3; } sub main { my %opts = ('desist' => 0, 'conmax' => 5, 'reqs' => 100); GetOptions(\%opts, qw/conmax=i reqs=i desist/) or usage(); usage() unless @ARGV == 1; my $url = shift @ARGV; unless ($url =~ m{\Ahttps?://}) { print STDERR "URL must have scheme of http[s].\n"; usage(); } $opts{'url'} = $url; my $start = AnyEvent->time; my ($times, $bytes) = benchgets(\%opts); my $elapsed = AnyEvent->time - $start; printstats({ 'reqs' => $opts{'reqs'}, 'elapsed' => $elapsed, 'times' => $times, 'bytes' => $bytes }); return 0; } sub benchgets { my ($opts) = @_; my ($conmax, $reqcount, $url, $desist) = @{$opts}{qw/conmax reqs url desist/}; my ($i, $bytes, $donecv, @times) = (0, 0, AnyEvent->condvar, ()); $donecv->begin for 1 .. $reqcount; my $clockget; $clockget = sub { my $reqbeg = AnyEvent->time; my $cb = sub { my ($body, $hdrs) = @_; die "HTTP @{$hdrs}{'Status','Reason'}" unless $hdrs->{'Status'} == 200; die 'Content length is zero' if length $body == 0; $bytes += length $body; my $t = AnyEvent->time - $reqbeg; push @times, $t; $donecv->end; # After each response is received, send out another reques +t. $clockget->() unless $i >= $reqcount; }; http_get($url, 'persistent' => !$desist, $cb); ++$i; }; # Start off a self-spawning batch of requests. $clockget->() for 1 .. $conmax; # Continue from here after the last response is received. $donecv->recv; return \@times, $bytes; } sub printstats { my ($opts) = @_; my ($reqcount, $elapsed, $T, $bytes) = @{$opts}{'reqs', 'elapsed', 'times', 'bytes'}; @$T = sort @$T; # makes min, max, median easier # Print simple statistics. printf "%0.3f seconds; %d requests (%0.1f/sec); %d bytes (%d/sec)\ +n", $elapsed, $reqcount, $reqcount / $elapsed, $bytes, $bytes / $e +lapsed; printf "%d min; %d mean; %d med; %d max; %d stdev\n", map { $_ * 1 +_000 } ($T->[0], mean($T), $T->[$#$T/2], $T->[$#$T], stdev($T)); return; } sub sum { my $a; $a += $_ for @{$_[0]}; $a } sub mean { sum($_[0]) / @{$_[0]} } sub stdev { my $a = shift; my $m = mean($a); sqrt mean([ map { ($_ - $m) ** 2 } @$a ]); } exit main(@ARGV);

In reply to Re^5: Threads and HTTPS Segfault by juster
in thread Threads and HTTPS Segfault by onelesd

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.