BoltDB作为后端数据库的性能

huangapple go评论73阅读模式
英文:

BoltDB performance as a backend DB

问题

我正在考虑将BoltDB作为后端主数据库,并对我的Go代码有一些问题;我也需要你对将BoltDB作为主要后端数据库的看法。

  1. 我正在使用Go的net/http,并将boltDb用作全局变量。
  2. 程序启动时,它会读取BoltDB,并且文件会一直保持打开状态,直到程序终止。
  3. 当请求(http)发送到程序时,它会访问BoltDB(HandleFunc)。
  4. 我没有使用任何通道。

Q1. 最重要的问题是,BoltDB能够处理1000个并发连接的生产环境吗?
Q2. 如果有并发的写入查询,BoltDB会自动逐个处理吗?

非常感谢。我对Go和BoltDB都是新手,我想知道我是否以正确的方式使用了正确的数据库。

英文:

I am thinking about using BoltDB as a backend main DB and have few question with my Go code; also need your opinion of using BoltDB as a main backend DB.

  1. I am using Go's net/http, and use boltDb as global variable.
  2. When the program starts, it will read BoltDB and the file is open until the program terminates.
  3. When requests(http) are sent to the program, it will access BoltDB. (HandleFunc)
  4. I didn't use any channel.

Q1. Most important question, is BoltDB capable for production with 1000 concurrent connection?
Q2. If there were concurrent writing queries, will BoltDB automatically process one by one?

Thank you so much. I am new to Go and BoltDB and I am wondering if I am using right DB with right way.

答案1

得分: 7

A1. 是的,我们使用它处理超过1000个并发连接。

A2. 是的,Bolt是线程安全的。当你调用db.Update时,它会锁定数据库,所以你的数据始终是一致的。

另外一个提示是,在update函数中不要进行任何繁重的操作。

英文:

A1. Yes, we use it with way more than 1000 concurrent connections.

A2. Yes, bolt is thread safe, when you call db.Update, it will lock the database, so you know you data will always be consistent.

Also a hint, never do any heavy lifting inside the update func.

huangapple
  • 本文由 发表于 2016年3月30日 11:09:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/36298925.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定