I am implementing a REST API using Spring Boot and @RestController
with Java 8. One of the controller methods needs to invoke another, 3rd party REST API service. The method is outlined as follows (data format is JSON):
- Call a 3rd party API method to get a list of candidates (each candidate is represented as an object with some basic information).
- For each candidate, call another 3rd party API method to get some more detailed information about the candidate.
- Mash up the results, essentially "enriching" all the candidate objects from the first call.
- Return the list of enriched candidate objects.
I was planning on using @RestTemplate
for all invocations on the 3rd party API. What I am concerned about is that for a large number of candidates (say 500-1000), this is going to become a huge performance bottleneck if implemented in a blocking fashion. I am not quite sure what is the recommended approach for best performance. How can I scale this so multiple users can concurrently access my API?