Reputation: 29
I currently have a program that takes in a query from a user via REST (Spring)and runs it across the database and returns the results via REST. The issue I'm running into is that if the user queries for a large set of data, at a certain point the server runs into a out of memory error.
Is there a way to stream the results using REST Spring to avoid the out of memory error? I've been researching and it seems like HTTP Chunked Encoding might be an option.
Upvotes: 2
Views: 4509
Reputation: 274
I would recommend looking at the new Spring repository streamAll functionality. I found the article linked below tremendously helpful (though quite old).
I am using this approach myself to stream pretty large datasets and I have no memory issues. The secret sauce is to limit the fetch size as described in the article below.
Upvotes: 0
Reputation: 36
Maybe SSE (https://en.wikipedia.org/wiki/Server-sent_events) can help you. SSE is a web technology where a browser receives updates from a server via HTTP connection. Examples:
Upvotes: 1