benschmaus / nodeload

HTTP load/traffic generator and benchmark tool built on Node.js
MIT License
399 stars 73 forks source link

HTTPS Support? #9

Open franklywatson opened 13 years ago

franklywatson commented 13 years ago

I was checking this out (very cool tool) for testing some HTTPS stuff were doing... I didn't see any explicit support for it mentioned anywhere, so I played around with the code and tried the quick and easy way of changing all the

require('http')

to

require('https')

However, connecting the clients to SSL seems not to work.. Has anyone done this or where else should I look?

Cheers

J

jonjlee commented 13 years ago

J --

There's no built in support for https, unfortunately, but nodeload can handle them. You can use the 'https' node.js module with a custom requestGenerator function like this:

var https = require('https');
var readtest = {
        name: "Read HTTPS",
        timeLimit: 60,
        targetRps: 10,
        requestGenerator: function(client) {
            return https.request({method: 'GET', host: 'encrypted.google.com', port: 443, path: '/'});
        }
    },
    loadtest = nl.run(readtest);

You can also do this with nl.js using the -r option (see examples/test-generator.js).

The one caveat is that I don't believe node.js supports persistent connections over HTTPS (let me know if find something to the contrary), so this may skew your results. When generating a large amount of load, you might run into an issue where your request rate suddenly drops to zero for several seconds. This happens when the system runs out of ephemeral ports used for outbound connections, and node.js is waiting for old ports to be cleaned up for reuse. Let me know if see something like that, and we can see if there's a way to work around it.

franklywatson commented 13 years ago

Hi Jon

That's great, looks like it works a charm! I've also been fiddling around with the report and would love to know how to modify the output to be CSV rather than JSON... It's not completely obvious to me what outputs this

Cheers

Jerome