BoltDB performance as a backend DB
Asked Answered
S

1

8

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.

Satsuma answered 30/3, 2016 at 3:9 Comment(0)
P
7

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.

Placard answered 30/3, 2016 at 4:24 Comment(3)
Thank you so much!Satsuma
You may want to add a *bolt.DB variable to an http.Handler implementation instead of a global variable so you can test it easier (and in parallel).Graceless
Also, it can handle high parallel read concurrency great but writes will be serialized. As long as your 1000 requests aren't all doing writes (or they're doing small writes) you should be fine.Graceless

© 2022 - 2024 — McMap. All rights reserved.