cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
5457
Views
10
Helpful
5
Replies

RESTCONF vs REST API huge difference between response times

DanielSan6998
Level 1
Level 1

Hi guys, I'm migrating REST API calls to RESTCONF calls, but RESTCONF is underperforming at any request.

 

For example:

http://127.0.0.1:8080/restconf/data/devices/device=OriHuaDemo

response time is 22 seconds

But the same query with REST API:

http://127.0.0.1:8080/api/operational/devices/device/OriHuaDemo

response time is 6 seconds

 

Do you have any clue why this is happening? it's a normal behavior?

 

I tried also CLI and JSONRPC, both faster, this performance issue seems to be RESTCONF specific.

 

1 Accepted Solution

Accepted Solutions

perander
Cisco Employee
Cisco Employee

@DanielSan6998 wrote:

Hi guys, I'm migrating REST API calls to RESTCONF calls, but RESTCONF is underperforming at any request.

First of all, happy to see that you are migrating from REST API to RESTCONF!

 

 

For example:

http://127.0.0.1:8080/restconf/data/devices/device=OriHuaDemo

response time is 22 seconds

But the same query with REST API:

http://127.0.0.1:8080/api/operational/devices/device/OriHuaDemo

response time is 6 seconds

 

Do you have any clue why this is happening? it's a normal behavior?

 

I tried also CLI and JSONRPC, both faster, this performance issue seems to be RESTCONF specific.

 


TL;DR It is probably not the same thing that is compared. RESTCONF is somewhat
faster for comparable payloads in benchmarks.

A normal GET request to RESTCONF is similar to using query parameters "verbose"
and "deep" for REST API. Otherwise the result payload will be very different, similar
in size order as the time difference presented.

On a new installation of NSO I performed these queries

REST API

$ time curl -isu admin:admin localhost:8080/api/operational?verbose\&deep | wc -l
3547

real 0m0.235s
user 0m0.015s
sys 0m0.034

Not using the "verbose" and "deep" query parameters will yield about half the
lines of payload, and hence be faster.


Analog for RESTCONF

$ time curl -isu admin:admin localhost:8080/restconf/data | wc -l
3515

real 0m0.189s
user 0m0.014s
sys 0m0.004s

 

The tests have been run a number of times and consistently shows similar
results on my machine.

 

Example towards ncs-state where similar differences shows

$ time curl -isu admin:admin localhost:8080/api/operational/ncs-state | wc -l
379

real 0m0.024s
user 0m0.007s
sys 0m0.010s

$ time curl -isu admin:admin localhost:8080/api/operational/ncs-state?verbose\&deep | wc -l
956

real 0m0.065s
user 0m0.022s
sys 0m0.000s

$ time curl -isu admin:admin localhost:8080/restconf/data/tailf-ncs-monitoring:ncs-state | wc -l
955

real 0m0.058s
user 0m0.000s
sys 0m0.016s

 

The results show that RESTCONF is somewhat faster on comparable payloads.

 

There are still some things that can be done to tweak RESTCONF performance
of course, which we are discussing.

 

It would be interesting to see benchmarks comparing REST API, RESTCONF,
CLI, and JSON-RPC, please send us your findings!

View solution in original post

5 Replies 5

lmanor
Cisco Employee
Cisco Employee

I also see a difference REST vs RESTCONF for the get of the same operational item ncs-state, but not as marked as you test case.

I'm seeing RESTCONF 168 msec vs REST 55 msec (NSO version 5.2.0.1, request from the same server, port 8080)

The path in your url for your RESTCONF call /restconf/data/ncs-data actually fails when I attempt the GET:

http://127.0.0.1:8080/restconf/data/ncs-state

 

Status: 400 Bad Request

<errors xmlns="urn:ietf:params:xml:ns:yang:ietf-restconf">
    <error>
        <error-message>missing module name for 'ncs-state'</error-message>
        <error-tag>missing-attribute</error-tag>
        <error-type>application</error-type>
    </error>
</errors
 
However, when I add the module for ncs-state:
I successfully get a response. 
I'm not sure how/why you are seeing success when providing a path with no module name.
I wonder if you provide the module name in your path if your RESTCONF performance will get better.

 

NSO Version you are using?

 

perander
Cisco Employee
Cisco Employee

@DanielSan6998 wrote:

Hi guys, I'm migrating REST API calls to RESTCONF calls, but RESTCONF is underperforming at any request.

First of all, happy to see that you are migrating from REST API to RESTCONF!

 

 

For example:

http://127.0.0.1:8080/restconf/data/devices/device=OriHuaDemo

response time is 22 seconds

But the same query with REST API:

http://127.0.0.1:8080/api/operational/devices/device/OriHuaDemo

response time is 6 seconds

 

Do you have any clue why this is happening? it's a normal behavior?

 

I tried also CLI and JSONRPC, both faster, this performance issue seems to be RESTCONF specific.

 


TL;DR It is probably not the same thing that is compared. RESTCONF is somewhat
faster for comparable payloads in benchmarks.

A normal GET request to RESTCONF is similar to using query parameters "verbose"
and "deep" for REST API. Otherwise the result payload will be very different, similar
in size order as the time difference presented.

On a new installation of NSO I performed these queries

REST API

$ time curl -isu admin:admin localhost:8080/api/operational?verbose\&deep | wc -l
3547

real 0m0.235s
user 0m0.015s
sys 0m0.034

Not using the "verbose" and "deep" query parameters will yield about half the
lines of payload, and hence be faster.


Analog for RESTCONF

$ time curl -isu admin:admin localhost:8080/restconf/data | wc -l
3515

real 0m0.189s
user 0m0.014s
sys 0m0.004s

 

The tests have been run a number of times and consistently shows similar
results on my machine.

 

Example towards ncs-state where similar differences shows

$ time curl -isu admin:admin localhost:8080/api/operational/ncs-state | wc -l
379

real 0m0.024s
user 0m0.007s
sys 0m0.010s

$ time curl -isu admin:admin localhost:8080/api/operational/ncs-state?verbose\&deep | wc -l
956

real 0m0.065s
user 0m0.022s
sys 0m0.000s

$ time curl -isu admin:admin localhost:8080/restconf/data/tailf-ncs-monitoring:ncs-state | wc -l
955

real 0m0.058s
user 0m0.000s
sys 0m0.016s

 

The results show that RESTCONF is somewhat faster on comparable payloads.

 

There are still some things that can be done to tweak RESTCONF performance
of course, which we are discussing.

 

It would be interesting to see benchmarks comparing REST API, RESTCONF,
CLI, and JSON-RPC, please send us your findings!

I see -- - rest-api: The REST API is deprecated and will be removed in NSO-5.3.
Users of the REST API should use the RESTCONF API instead,
see NSO Northbound APIs: Migrating from REST to the
RESTCONF API.

(ENG-20521)  in the CHANGES text of 5.1.0.1 NSO  - wanted to see if anyone has experience with migration they can share 

perander
Cisco Employee
Cisco Employee
Hey! Did the answer I gave clarify anything?