Huge json object generation through Restful webservice in spring framework - spring

I am new into designing a RESTFul webservice and I have to design a webservice that is going to respond one get method.
Below are the points that I have keep in mind.
Webservice will accept start and end date.
We have to hit the database and have to return the data in form of json/xml. Json object that needs to be returned is having three fields.
Data is containing large amount of json object and the webservice is going to be called every minute.
I need to understand the best practice to design such RESTFul webservice. Because the major challenge that I feel is webservice is going to be called every minute and we cannot afford of creating new object that finally returned as JSON or XML objects. We cannot cache the results because data is going to change every minute.
Please help.
Thanks in advance.

Related

Differentiate between GET and POST method in Laravel Controller REST API

Differentiate between GET and POST method in Laravel cake Controller REST API
There is concept of REST. REST is an architectural style and a design for network-based software architectures.It is not much specific on Programming language based.
Follow this thread.
what-is-rest-slightly-confused
GET requests a representation of the specified resource. Note that GET should not be used for operations that cause side-effects, such as using it for taking actions in web applications. One reason for this is that GET may be used arbitrarily by robots or crawlers, which should not need to consider the side effects that a request should cause.
POST submits data to be processed (e.g., from an HTML form) to the identified resource. The data is included in the body of the request. This may result in the creation of a new resource or the updates of existing resources or both.
GET - Retrieves Information (For eg: Providing response with some lists of data
from the database)
POST - Consumes provided resource and do the specified actions (For eg: Storing
form data in the database)
You can go through this: https://vimeo.com/17785736
GET - Retrieves Information (For eg: Providing response with some lists of data from the database) POST - Consumes provided resource and do the specified actions (For eg: Storing form data in the database

Model derivative API returns no data for hierarchy or properties

When retrieving data from model derivative API it returns status success, but no data. This happens intermittently; running the query on the same model will eventually return the data - sometimes first try, other times after several tries. It is set to SVF 3D. What am I missing?
This is a known issue with those endpoints, we have logged that and our development team is aware of it. As a workaround, at the moment, you will need to implement a retry policy in your code, sorry for the bad news.
Also to ease the large payload returned by the /properties endpoint when the model contain a lot of components we have implemented a new endpoint which lets you specify the dbId to return properties for. It should be available on the public API in the near future.
Hope that helps.

Event Triggered Workflows

I´m writing a software that work to process a set of data that came from use input process it and send an answer to the user.
The flow starts based on a configured API Callthat start a chain of API calls passing the result of each API for the next one until reachs the final output.
The problem is that the chain of calls is configurable by the user in order to process the data before saving it to the database.
Giving you a little example:
I receive data from an API that has the readings from a field sensor, on the arrival of this data I should do the following things:
Save the data on the database
Process the Data
Based on the data and on a configuration that should be made by the user I should get information from a diferent API (the APIs depend on the content of the data)
Send the information that I got from the other API to a third which will send it back to the sensor
Do you know any solution that´s capable of doing this kind of work?
Doesn´t mather the language or the framework, since it´s a brand new software we are free to start from the very first step.
Thank you
I am considering that, You have a form where user entering the Data, you are receiving the data, processing it and returning the answer based on the Data and your set of rules.
If you have a single form, get the data and pass to the API - RESTFul API
Process the data at server end
Response to client based on the set of rules of user entered data.
If you have Multiple form and coming to user one after one then do same.
Hope the process works. if you could clarify the Requirement more specifically then I can draw the Process in more depth.

Parse.com. Execute backend code before response

I need to know the relative position of an object in a list. Lets say I need to know the position of a certain wine of all wines added to the database, based in the votes received by users. The app should be able to receive the ranking position as an object property when retrieving a "wine" class object.
This should be easy to do in the backend side but I've seen Cloud Code and it seems it only is able to execute code before or after saving or deleting, not before reading and giving response.
Any way to do this task?. Any workaround?.
Thanks.
I think you would have to write a Cloud function to perform this calculation for a particular wine.
https://www.parse.com/docs/cloud_code_guide#functions
This would be a function you would call manually. You would have to provide the "wine" object or objectId as a parameter and then get have your cloud function return the value you need. Keep in mind there are limitations on cloud functions. Read the documentation about time limits. You also don't want to make too many API calls every time you run this. It sounds like your computation could be fairly heavy if your dataset is large and you aren't caching at least some of the information.

Performance and instances in java servlet

I am building a servlet (e.g. MainServlet) where, in order to be thread-safe, I am creating an object (e.g. MainServletProcesor) and then delegating the call to the object to process the HttpRequest. The MainServletProcessorhas instance members that are used to fulfill the request. I was wondering if this approach is fine from a performance point of view. Is this approach of creating a Processor instance per request a good idea?
Your Servlet doXYZ() methods are entry points (your point of view) for your application. If you were to write all the logic for request handling in each of those methods, your code would very quickly become unmanageable.
What you are doing is completely reasonable and actually good practice. Creating an object takes almost no time at all. When your Servlet container receives the actual HTTP request, it actually goes and creates a ton of objects (HttpServletRequest, HttpServletResponse, Streams, Headers, etc.) without you seeing it.
You can have a look at the request processing flow for Tomcat here. This won't show you what objects are created for each request, but you can extrapolate (or look at the source code).
Why wouldn't it? Creating an object is cheap, and during the processing and rendering of your request, you probably create a lot more of them.
Creating an object is several orders of magnitude faster than querying a database, or writing the response to the output stream.

Resources