To build api for a large scale application, which method is better interms of performance, should i use Rabl, Jbuilder or build json objects manually?I am building api /endpoints for mobile apps.
相关问题
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Question marks after images and js/css files in ra
- Using :remote => true with hover event
相关文章
- 我用scrapy写了一个蛮简单的爬虫怎么封装成一个api啊
- 后端给前端的API接口是怎么用代码写的
- json_encode 没有把数组转为json
- Livy Server: return a dataframe as JSON?
- Right way to deploy Rails + Puma + Postgres app to
- Unexpected end of JSON input from an ajax call
- AWS S3 in rails - how to set the s3_signature_vers
- how to call a active record named scope with a str
In terms of performance, you should try creating some basic performance tests, and profile them.
Assume the most complicated part of your application's model associations is your weakest point in terms of responsiveness and design your test around that.
Generally speaking there are a few other things you should take into consideration.
as_json
overrides will quickly get out of hand in your models, and become a brittle part of your application. Many people consider an API as a view, and therefore the logic for it should be separated away from the Model, to remain flexible/interchangeable and testable. This is the main advantage of both JBuilder and RABL. Ultimately even a simple JSON api built withas_json
will be begging for refactoring when they need to be extended, so it's probably worth the initial complexity of learning/using a DSL. That said, there are certainly some cases where it's perfectly ok to useas_json
you just need to be aware of problems with scalability and maintenance.Jbuilder used to have quite poor performance, however this was deeply improved about the same time as this question was first posted. Before that RABL was way more performant. At this point, Jbuilder is a touch faster.
RABL's DSL is generally less favored than Jbuilder's, it can be a difficulty in getting started, and in later maintenance. Jbuilder's DSL is generally speaking, simpler and easier to learn/use, in both cases YMMV, but the general consensus appears to be that Jbuilder is easier to pick up and run with.
Since this question is 5 months old, sorry I didn't see it sooner, I expect the decision has long ago been made.
I suggests Jbuilder. Because Jbuilder has core development of Rails. So at the time of upgradation it may not create problem.