3scale-labs / 3scale_ws_api_for_nodejs

3scale is an API Infrastructure service which handles API Keys, Rate Limiting, Analytics, Billing Payments and Developer Management. Includes a configurable API dashboard and developer portal CMS. More product stuff at http://www.3scale.net/, support information at http://support.3scale.net/.
http://www.3scale.net
MIT License
22 stars 13 forks source link

3scale response times for authorization #48

Closed petermorlion closed 7 years ago

petermorlion commented 7 years ago

I'm working on a NodeJS application that calls 3scale to see if the calling client is authorized to call our endpoint. This is a simple as calling the client.authorize function. However, I've measured it, and it takes about 300-400 ms. Only then can my code continue. We're very focussed on performance now and business wants to achieve speeds of 300-500 ms. As you can see, this leaves little room for our application logic.

This is how I measured it:

console.time('Authorize');
client.authorize({
    'app_id': appId,
    'app_key': appKey
},
(response) => {
    console.timeEnd('Authorize');
    // ...
});

We also report endpoint usage (via the separate function, not yet via authrep), and those calls are significantly faster (12ms for example).

Is the 300-400 ms for authorizing something expected? Or could I be doing something wrong?

If it's something expected, do you see workarounds to increase performance? One option would be to cache the authorization responses, so we don't need to request it every time the endpoint is called.

MarkCheshire commented 7 years ago

This response time varies mainly depending on the network connection between your location and the 3scale data center running on AWS-East. The actual authorization service itself is very fast.

You are correct that it would be good to cache the auth responses. This is a reason that many customers choose to go with the APIcast Gateway because we integrate an eventual consistency cache by default.

At the end of the day the choice is yours.

petermorlion commented 7 years ago

Great, thanks for the quick reply. I will look into these options.