Hi,

When creating a REST API to WSO2 machine learner, one of the important
problems I faced was selection among fine grained resources and coarse
grained resources. In other words, whether to define something as a
separate resource or a part of a large resource.

Fine grained Resources are low complex and easy to maintain. But it can
make data become an inconsistent state and the server will end up receiving
higher number of HTTP requests possibly impacting its ability to serve
multiple API consumers.

In using coarse grained resources, the data inconsistency and higher load
on the server is reduced. But it may be difficult to maintain and higher
JSON payload may be returned.

For example, we have an API GET api/analysis/analysis_id/configs which
retrieves configurations of an API. The problem is whether to use a
separate resource for configs or return configs with the analysis resource.
If we consider configuration as a separate resource, we have to define an
API, GET api/analysis/analysis_id/configs. But if we return configs with
analysis resource, then it may be only the API GET
api/analysis/analysis_id  and the configuration should be added to analysis
resource and returned with it.

I have found an approach to solve the problem and given below is what I
have understood.

The decision should be taken considering the situation.

Here, the decision is based on the size of the configuration object. If it
has a large size, then if we return it with analysis resource, it may be a
large JSON payload and time wastage because every time an analysis resource
is returned configuration also have to be returned even not necessary.
Therefore, if configuration is large, it is better to use a separate
resource for configurations and use a separate API as
api/analysis/analysis_id/configs

But, when we have to access a simple property such as algorithm-name of the
analysis, then it is better to return it with algorithm resource.

This is the approach I have decided and highly appreciate your suggestions
on this.


Thanks
_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to