本地SQLite vs远程MongoDB [英] Local SQLite vs Remote MongoDB

查看:172
本文介绍了本地SQLite vs远程MongoDB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在设计一个新的Web项目,在研究了可扩展性的一些选项后,我提出了两个数据库解决方案:




  • 本地SQLite文件精心设计为可扩展的方式(每个X用户一个新的数据库文件,因为写入将取决于用户内容,没有跨用户数据依赖);

  • 远程MongoDB服务器(如 Mongolab ),因为我的主机服务器不提供MongoDB。



我不信任MySQL服务器在当前的共享主机,因为它下降很频繁(我也有在另一个主机上的MySQL的问题)。因为同样的原因,我不会去使用postgres。



SQLite的优点:




  • 它是本地的,所以它必须更快(我会照顾使用索引和事务正确);

  • 我不需要担心tcp嗅探,如Mongo有线协议未被加密;

  • 我不需要担心服务器中断,因为SQLite是无服务器的。



MongoDB的优点: / p>


  • 更容易扩展;

  • 我不需要担心分割数据库,因为可扩展性似乎很自然;

  • 我不需要担心模式的变化,因为Mongo是模式,而 SQLite不完全支持alter table (特别考虑更改许多生产文件等)。



我想帮忙做出决定(也许考虑第三个选择)。写/读操作越多,哪一个更好?



我要使用Ruby。

解决方案

SQLite方法的一个主要风险是,随着您的扩展需求的增加,您将无法(轻松)在多个应用程序服务器上部署。您可能可以将用户划分为不同的服务器,但是如果该服务器停止运行,那么您将有一些用户无法访问其数据的子集。



使用MongoDB(或任何其他集中式服务)可以缓解此问题,因为您的Web服务器是无状态的 - 可以随时添加或删除它们以适应网络载入,而无需担心哪些数据在哪里。


I'm designing a new web project and, after studying some options aiming scalability, I came up with two database solutions:

  • Local SQLite files carefully designed for a scalable fashion (one new database file for each X users, as writes will depend on user content, with no cross-user data dependence);
  • Remote MongoDB server (like Mongolab), as my host server doesn't serve MongoDB.

I don't trust MySQL server at current shared host, as it cames down very frequently (and I had problems with MySQL on another host, too). For the same reason I'm not goint to use postgres.

Pros of SQLite:

  • It's local, so it must be faster (I'll take care of using index and transactions properly);
  • I don't need to worry about tcp sniffing, as Mongo wire protocol is not crypted;
  • I don't need to worry about server outage, as SQLite is serverless.

Pros of MongoDB:

  • It's more easily scalable;
  • I don't need to worry on splitting databases, as scalability seems natural;
  • I don't need to worry about schema changes, as Mongo is schemaless and SQLite doesn't fully support alter table (specially considering changing many production files, etc.).

I want help to make a decision (and maybe consider a third option). Which one is better when write and read operations is growing?

I'm going to use Ruby.

解决方案

One major risk of the SQLite approach is that as your requirements to scale increase, you will not be able to (easily) deploy on multiple application servers. You may be able to partition your users into separate servers, but if that server were to go down, you would have some subset of users who could not access their data.

Using MongoDB (or any other centralized service) alleviates this problem, as your web servers are stateless -- they can be added or removed at any time to accommodate web load without having to worry about what data lives where.

这篇关于本地SQLite vs远程MongoDB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆