简体   繁体   English

使用SQLite作为生产数据库,但不好的想法

[英]Using SQLite as production database, bad idea but

We are currently using postgresql for our production database in rails, great database, but I am building the new version of our application around SQLite. 我们目前正在使用postgresql作为我们在rails中的生产数据库,很棒的数据库,但我正在围绕SQLite构建我们的应用程序的新版本。 Indeed, we don't use advanced functions of postgres like full text search or PL/SQL. 实际上,我们不使用postgres的高级功能,如全文搜索或PL / SQL。 Considering SQLite, I love the idea to move the database playing with just one file, its simple integration in a server and in Rails, and the performance seems really good -> Benchmark 考虑到SQLite,我喜欢用一个文件移动数据库的想法,它在服务器和Rails中的简单集成,性能似乎非常好 - > Benchmark

Our application's traffic is relatively high, we got something like 1 200 000 views/day. 我们的应用程序的流量相对较高,我们每天的观看次数达到了120万次。 So, we make a lot of read from the database, but we make a few writes. 因此,我们从数据库中进行了大量读取,但是我们做了一些写操作。

What do you think of that ? 你对那个怎么想的 ? Feedback from anyone using or trying (like us) to use SQLite like a production database ? 任何使用或尝试(像我们)使用SQLite像生产数据库的人的反馈?

If you do lots of reads and few writes then combine SQLite it with some sort of in-memory cache mechanism ( memcache or redis are really good for this). 如果你进行大量的读取和少量写入,那么将SQLite与某种内存缓存机制结合起来( memcacheredis对此非常有用)。 This would help to minimize the number of accesses (reads) to the database. 这将有助于最小化对数据库的访问(读取)次数。 This approach helps on any many-reads-few-writes environment and it helps to not hit SQLite deficiencies - in your specific case. 这种方法有助于任何多读取少量写入环境,并且在特定情况下有助于不会遇到SQLite缺陷。

SQLite is designed for embedded systems. SQLite专为嵌入式系统而设计。 It will work fine with a single user, but doesn't handle concurrent requests very well. 它可以与单个用户一起使用,但不能很好地处理并发请求。 1.2M views per days probably means you'll get plenty of the latter. 每天1.2M的观看次数可能意味着你将获得足够的后者。

For doing only reads I think in theory it can be faster than an out-of-process database server because you do not have to serialize data to memory or network streams, its all accessed in-process. 对于仅进行读取,我认为理论上它可以比进程外数据库服务器更快,因为您不必将数据序列化到内存或网络流,它们都在进程中访问。 In practice its possible an RDBMS could be faster; 在实践中,它可能更快; RDBMS可能更快; for example MySQL has pretty good query caching features and for certain queries that could be an improvement because all your rails process would use this same cache. 例如,MySQL具有非常好的查询缓存功能,对于某些可能是改进的查询,因为所有的rails进程都会使用相同的缓存。 With sqllite they would not share a cache. 使用sqllite,他们不会共享缓存。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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