[#341] Performance issue with api

Migrated from Redmine #341 | Author: Keith Lyne
Status: New | Priority: Normal | Created: 2019-02-15


I’m having a performance issue with api.

It is taking 7-8 seconds for the sequence, i.e., login and getEventList() functions

I have tried a few options to speed it up but no luck.
One of the things I tried was to cache the token and not do login in every API call.

With the token caching I could get to 5 seconds. 5 seconds is very slow.

The online version, is using v2 of their API. That is pretty fast.

is it possible to get access to your V2 API

sample code

https://cl.ly/8619f5c82d0b

function getClient(){

var jrc = require(‘./json-rpc-client.js’);

var loginClient = new jrc.JSONRpcClient({

‘url’: ‘https://user-api.simplybook.me’ + ‘/login’,

‘onerror’: function (error) { },
});

var YOUR_COMPANY_LOGIN = ‘mygp’

var YOUR_API_KEY = ‘gjgkj’

// var token = ‘yjgjhg’;

var token = loginClient.getToken(YOUR_COMPANY_LOGIN, YOUR_API_KEY);

console.log(token);

return new jrc.JSONRpcClient({

‘url’: ‘https://user-api.simplybook.me’,

‘headers’: {

‘X-Company-Login’: YOUR_COMPANY_LOGIN,

‘X-Token’: token
},

‘onerror’: function (error) { console.log(error) }

});
}

function bookAppointmentHandler(agent) {

console.log(‘Starting book appointment’);

this.client = getClient();

console.log(‘got time’);

let services = this.client.getEventList();

Object.keys(services).forEach(function(key){

var service = services[key];

console.log(‘service unit map,’,service.unit_map);

agent.add(new Card({

Redmine Admin wrote:

please provide function with params which call is taking too much time.

Keith Lyne wrote:

getEventList() function is taking time. We are not passing any extra parameters
You can see in the attached code.

function bookAppointmentHandler(agent) {
console.log(‘Starting book appointment’);
this.client = getClient();
console.log(‘got time’);
let services = this.client.getEventList();
Object.keys(services).forEach(function(key){
var service = services[key];
console.log(‘service unit map,’,service.unit_map);

Redmine Admin wrote:

here is my test code

it took float(0.15135383605957) seconds to call getEventList()

float(0.28516602516174) for all code with login functions call

Keith Lyne wrote:

ok will look again.

have noticed the following, should I be using simplybook.it?

C:\Users\keith>ping user-api.simplybook.it

Pinging user-api.simplybook.it [137.74.201.231] with 32 bytes of data:
Reply from 137.74.201.231: bytes=32 time=29ms TTL=50
Reply from 137.74.201.231: bytes=32 time=90ms TTL=50
Reply from 137.74.201.231: bytes=32 time=37ms TTL=50
Reply from 137.74.201.231: bytes=32 time=29ms TTL=50

Ping statistics for 137.74.201.231:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 29ms, Maximum = 90ms, Average = 46ms

C:\Users\keith>ping user-api.simplybook.me

Pinging user-api.simplybook.me [158.69.26.11] with 32 bytes of data:
Reply from 158.69.26.11: bytes=32 time=101ms TTL=49
Reply from 158.69.26.11: bytes=32 time=101ms TTL=49
Reply from 158.69.26.11: bytes=32 time=138ms TTL=49
Reply from 158.69.26.11: bytes=32 time=101ms TTL=49

Ping statistics for 158.69.26.11:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 101ms, Maximum = 138ms, Average = 110ms

Redmine Admin wrote:

yes, your company is located on EU server. Better to use simplybook.it endpoint

Keith Lyne wrote:

I’ve tried this again, and still getting 6/7 seconds every time.

i’m use node.js vs php but I cant see how there could be such a time diff.

I’ve attached screenshots of the time delays i’m seeing.

Redmine Admin wrote:

We are not familiar with node.js unfortunately. We did perform tests on your account and response time is less than 0.2 sec as you can see.