简体   繁体   中英

Connecting heroku hosted rails app to a separate service that I created

I am currently hosting a Rails 3.2.11 application on heroku. I would like to create a separate application that the rails application will use as a service. I have not yet decided on the exact API or implementation. I expect there to be many more reads than writes and it is more important that the reads be fast. At least initially, only my Rails app will be accessing the service.

My current approach was going to be just to create the service as another heroku application. The rails app would consume it using HTTParty or some other library. Will this naive approach work well?

Ideally, I would like the communication between the two apps to be optimized because of the fact that they are both running on heroku. However, I would also like the rails app to be unconcerned with the location/implementation details of the service; it should continue working even if I moved the service to a different host.

Is the simple HTTP service the best way to go given the information I have provided, or is there a better alternative?

I've created several sites and services such as you describe. The key, for me, was to develop my services to respond to RESTful actions, in both XML and later JSON. Once the services were in place my apps can easily make the necessary calls to retrieve data using those RESTful endpoints. Having both sites on one hosting company can make a difference if you're concerned about having a low latency to requests.

One of the great things about Ruby on Rails is that by it's nature it's very portable. I have moved sites from EngineYard to Heroku and back without any issue, and my users were never aware of the change.

One last comment: Never use Heroku as your sole Git repository. I always check my projects into my private remote at GitHub as well as into the Heroku repo.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM