01-23-2020 03:59 AM
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.
Solved! Go to Solution.
01-24-2020 04:25 AM
@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!
01-23-2020 07:27 AM - edited 01-23-2020 07:28 AM
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
NSO Version you are using?
01-24-2020 04:25 AM
@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!
05-13-2020 04:15 PM
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
05-14-2020 02:17 AM
srisikha@cisco.com wrote:
(ENG-20521) in the CHANGES text of 5.1.0.1 NSO - wanted to see if anyone has experience with migration they can share
There are some related questions asked previously.
https://community.cisco.com/t5/nso-developer-hub-discussions/nso-query-via-get-curl/td-p/4044836
02-17-2020 03:02 AM
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide