Welcome Guest, Not a member yet? Register   Sign In
Architectural Question: Web Application + RESTful Web Services
#1

[eluser]CodeIgniterNewbie[/eluser]
We are going to start working on a web app and would like to expose an API to it using REST. Is it a good idea to create the API first, then have the web app use the API for its functionality. This way, the exposed API is exactly the same as what the web app is actually using.

Additionally, there will be 2 teams working on the entire system: one for the web app, the other for the API. What's a good way to split development in such a way that Team A is not aware of Team B's code -- and vice versa? Do we use different servers and different SVN projects? Something else?
#2

[eluser]Phil Sturgeon[/eluser]
Definitely the best way is to create the REST API first then have the web-app using the service. Then you can have two totally seperate applications for API and web app, meaning access can be cut right down between Team A and Team B.
#3

[eluser]CodeIgniterNewbie[/eluser]
Thanks Phil.

Don't you think the web app might have some performance issues? Is it slower to use REST than to do CRUD in CI model?
#4

[eluser]Phil Sturgeon[/eluser]
It will of course be slower. Instead of calling a CI model directly, you are making a HTTP request which THEN makes the call to a model, but if it is running over localhost the difference will be negligable.

My EECI2009 slideshow should explain some of this: Igniting your web-service with REST.
#5

[eluser]CodeIgniterNewbie[/eluser]
What does "localhost" mean in this context? If the web app and web service are hosted on the same domain, the web app calling a web service will not be significantly slower than if it made direct calls to the model?
#6

[eluser]CodeIgniterNewbie[/eluser]
By the way, I already went through your slideshow. =) Wish the video would be posted too.
#7

[eluser]Phil Sturgeon[/eluser]
If web-app and REST API are on the same server then it will be quicker than having them on separate servers as it cuts out DNS propegation on each request and means data transfer is quicker.

Using REST will never be quicker than a direct call to the database as you are always going to make that call at some point, wether in the web-app or in the REST API. The point is if they are on the same server it wont be slooooooooooow, just SLIGHTLY slower.
#8

[eluser]CodeIgniterNewbie[/eluser]
Would this be a good idea:

1. there is a model method foo() that the web app calls
2. there is a REST method foo(), which calls the model method foo()

In this scenario, the web app does not suffer any performance issues. I'm wondering if this approach can somehow become a maintenance nightmare, though.

Or is the difference truly negligible that it doesn't really matter?
#9

[eluser]Phil Sturgeon[/eluser]
Your example confuses me, but yeah the difference really is negligible. It's still probably quicker than using ORM :-)




Theme © iAndrew 2016 - Forum software by © MyBB