Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Optimize REST API Response time

am working on a E-commerce project which has internally four projects(parts).
1.) core -has users info
2.) cms-contents info
3.) oms-orders info
4.) wallet-payment info

Used:-
UI-AngularJs
Backend-java

  • No third paty api calls.
  • caching already used
  • only http calls among above four projects.

we have multiple REST API calls one after other to same domain(with different path and query parameters).

What are the ways that I can optimize api response time.

Suggestions for java and AngularJs is welcome,rather than caching give me more suggestions that i can use to optimize response time of api's.

Appreciated!!!

I have found same question on stackoverflow How to Optimize REST API calls ,answer is helpul but found no best solution for me.

like image 553
NeeruKSingh Avatar asked Oct 28 '17 06:10

NeeruKSingh


People also ask

What is a good response time for a rest API?

Generally, APIs that are considered high-performing have an average response time between 0.1 and one second. At this speed, end users will likely not experience any interruption. At around one to two seconds, users begin to notice some delay.

How do you improve API response?

Another way to improve the performance of your API calls is by sending and receiving only the portion of the data that you're interested in. This lets your application avoid transferring, parsing, and storing unneeded fields, so it can use resources including network, CPU, and memory more efficiently.

How do I increase the response time on Web API?

Compress the Result of Web API In the Web, the data transfers through the network in packages (data packets), increasing the size of the data package, which will increase the size as well as increase the response time of the Web API. Thus, reducing the data packet size improves the load performance of Web API.


2 Answers

Try using the below configurations for Java-spring projects :

# Enable response compression
server.compression.enabled=true

# The comma-separated list of mime types that should be compressed
server.compression.mime-types=text/html,text/xml,text/plain,text/css,text/javascript,application/javascript,application/json

# Compress the response only if the response size is at least 1KB
server.compression.min-response-size=1024

# Enable HTTP/2 support, if the current environment supports it
server.http2.enabled=true
like image 171
Cjo Avatar answered Sep 21 '22 02:09

Cjo


What is the current response time you have in ms and what you are aiming to?

A good cached Api should work at the java level around 1-30ms depends on the amount of content and the type of cachong you are using.

like image 22
Nir Sivan Avatar answered Sep 21 '22 02:09

Nir Sivan