开发者

Best place to host my Sproutcore app backed up by Cloudant CouchDB?

I have a Sproutcore application which uses Co开发者_C百科uchDB hosted by Cloudant. In devenv I'm using Sproutcore proxy to forward requests to Cloudant (due to single origin policy I obviously can't call a arbitrary hosts from my JavaScript).

What would be your suggestion on hosting the app. CouchApps loading script is failing with obscure error (please note Sproutcore app is around 40 MB of JavaScript and resources).


The thing about hosting an app that talks directly to couchdb is that you are restricted by the same origin policy, so the server that serves up your SproutCore app, has to be on the same domain as you access your couchDB database. If your host provides a static file server, you could use that, but your best bet is probably just to save it as a couch app.

The Key with deploying SC as a couch app, is that you have to set up the URL's that sc-build generates to point to the correct location. This can be done with the buildfile setting something like this:

:url_prefix => '<database>/_design/<designDocument>/'

This way the links point to the right location.

You can also setup CouchDB url rewrites to get simpler urls if you wish. Have a look here for more discussion on this:

https://groups.google.com/d/topic/sproutcore/-D-5T5yPg3A/discussion

PS: 40mb seems overly large! do you have many images? I'd be concerned if you had that much JS/CSS.


Cloudant hosts its clusters (mainly) on EC2 in the us-east-1b or us-west-1b availability zones. If you cannot deploy as a CouchApp you should try to colocate your application layer next to your DB cluster. That will minimize the latency between the web server and the databases.

You can do this yourself by getting an EC2 instance and running a web server on it, or you can use a third party host that hosts on AWS (e.g. Heroku).

In both cases, you will need to run a small proxy from your web server to the database. That's why simply hosting on S3 is not an option at the moment.

Once you deploy your app to a web server, don't forget to check that your web server and your database are in the same AWS availability zone. If they're not, just ask Cloudant to move your account.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜