托管由 Cloudant CouchDB 支持的 Sproutcore 应用程序的最佳位置?

发布于 2024-10-20 17:23:14 字数 227 浏览 7 评论 0原文

我有一个 Sproutcore 应用程序,它使用由 Cloudant 托管的 CouchDB。在 devenv 中,我使用 Sproutcore 代理将请求转发到 Cloudant(由于单源策略,我显然无法从 JavaScript 调用任意主机)。

您对托管该应用程序有何建议? CouchApps 加载脚本失败并出现模糊错误(请注意 Sproutcore 应用程序包含大约 40 MB 的 JavaScript 和资源)。

I have a Sproutcore application which uses CouchDB 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).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

谁把谁当真 2024-10-27 17:23:14

托管直接与 couchdb 对话的应用程序的问题是,您受到同源策略的限制,因此为您的 SproutCore 应用程序提供服务的服务器必须位于与您访问 couchDB 数据库相同的域中。如果您的主机提供静态文件服务器,您可以使用它,但最好的选择可能只是将其保存为沙发应用程序。

将 SC 部署为沙发应用程序的关键是您必须设置 sc-build 生成的 URL 以指向正确的位置。这可以通过构建文件设置来完成,如下所示:

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

这样链接就指向正确的位置。

如果您愿意,您还可以设置 CouchDB url 重写以获得更简单的 url。请查看此处,了解更多相关讨论:

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

PS:40mb 似乎太大了!你有很多图片吗?如果你有那么多 JS/CSS 我会担心的。

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.

吖咩 2024-10-27 17:23:14

Cloudant 将其集群(主要)托管在 us-east-1b 或 us-west-1b 可用区的 EC2 上。如果您无法部署为 CouchApp,您应该尝试将应用程序层与数据库集群并置。这将最大限度地减少 Web 服务器和数据库之间的延迟。

您可以通过获取 EC2 实例并在其上运行 Web 服务器来自己完成此操作,也可以使用托管在 AWS 上的第三方主机(例如

在这两种情况下,您都需要运行一个从 Web 服务器到数据库的小型代理。这就是为什么仅仅在 S3 上托管目前不是一个选择。

将应用程序部署到 Web 服务器后,请不要忘记检查您的 Web 服务器和数据库是否位于同一 AWS 可用区。如果不是,只需要求 Cloudant 移动您的帐户。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文