Erlang:2 个网络服务器上的 2 个数据库?

发布于 2024-08-25 02:30:48 字数 296 浏览 5 评论 0 原文

我用php+postgresql创建了一个博客系统。 现在我想添加一个网络聊天(同时为数百万用户实时提供),其中每条消息都保存在数据库中。

我正在考虑在不同的网络服务器上使用 Erlang+Mnesia 来解决这个问题。

消息的表将如下所示:

message_id、user_id、message、date

user_id 应该与另一个网络服务器中的 Postgresql 数据库中的用户表相关。

我怎样才能做到这一点而不损失性能?

如果您有任何其他创意解决方案,请告诉我;)。

I have created a blogging system with php+postgresql.
Now I want to add a web chat ( in REAL TIME for Million of users simultaneously ) where every message is saved in database.

I am thinking to use Erlang+Mnesia on a different webserver for this issue.

Message's table will be like this:

message_id, user_id, message, date

user_id should be related with users table in Postgresql database in another webserver.

How can I do that without lose performance ?

If you have any other creative solutions tell me please ;).

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

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

发布评论

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

评论(3

青巷忧颜 2024-09-01 02:30:48

我不确定为什么你想将每条消息保存在数据库中,但 mnesia 听起来并不是一个特别好的选择。 Mnesia 更像是一个分布式键值存储,当您需要以简单到中等复杂的方式存储“表格数据”并查询它时,您可以使用它来保存应用程序的状态。

对于大量文本,我听说 lucene 应该很好,它具有全文搜索功能等,据说很有效,你可能想研究一下:

Apache Lucene 项目页面

除此之外,使用 erlang 作为聊天服务器,使用 mnesia 来保存所有其他状态听起来是个好主意,您可以编写一个 JavaScript 客户端,使用 JSONP(以克服跨域问题)和 erlang 站点上的 mochiweb 之类的东西来完成 Web 服务器部分。

编写核心聊天系统的其余部分应该相当简单,可以说是有趣的部分:)

I'm not sure why you want to save every single message in a database, but mnesia doesn't sound like a particularly good choice for doing that. Mnesia is more of a distributed key-value store, that you can use to keep the state of your application, when you need to store "tabular data" and query it, in a simple to medium-complex fashion.

For large amounts of text, I've heard lucene is supposed to be good, it has fulltext search features etc. which are said to be efficient, you might want to look into it:

Apache Lucene Project page

Other than that, using erlang as chatserver, using mnesia to hold all the other state sounds like a good idea, You could write a javascript client that uses something like JSONP (to overcome the cross-domaine-issue) and mochiweb on the erlang site to do the webserver part.

Writing the rest of the core chat system should be fairly simple, the fun part, so to say :)

-残月青衣踏尘吟 2024-09-01 02:30:48

Mnesia 当然可以按照您的建议进行操作,但是如果您已经设置了 postgres,是否有什么原因您不想使用它?它可能比创建一个完整的单独服务更简单,如果您希望 erlang 运行聊天服务,那么它有 postgres 驱动程序。

Mnesia can certainly do what you suggest but if you've already got postgres set up is there some reason you don't want to use that? It might be simpler than creating a whole seperate service and if you want erlang to run the chat service then it has postgres drivers.

沉睡月亮 2024-09-01 02:30:48

该项目使用 postgresql 取得了巨大成功。

http://zotonic.com/

您可能希望使用相同的代码来访问 postgresql 的数据库。

This project is using postgresql with great success.

http://zotonic.com/

You may want to use the same code for db access to postgresql.

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