V
V
Vladimir Grabko2016-05-20 23:59:07
NoSQL
Vladimir Grabko, 2016-05-20 23:59:07

Is it worth it to do so?

Now I want to try something new (get away from standard databases like muscle and postgres). I made a service in which I hardcoded data structures (like tables), and a similar system acts as an index

//структура юзеров
type User struct{
  login string
  email string
}
//первичный индекс int == id. Он используется в индексах других таблиц
var UserId  map[int]User
//индекс на логин где string индекс, а int хранит ключ для массива UserId
var UserIndexLogin map[string]int

So far, when writing / updating, I encode the whole thing in json and save it to a file. Then I will improve this algorithm by creating a bunch of small ones instead of a huge json of the entire table (one id == one json of all structures). But I'm afraid that there will be problems with this (how the file system will react to 100k small files in one directory ...) so I think to replace fs with NoSql DB only that's all I found store data in RAM, and I need a secure (guaranteed) write to disk.
Since the RAM will not be enough sooner or later, I made an array that stores the UnixTime of the last access to each of the id and those that have not been accessed for a long time I stupidly delete.
But I still have not figured out how you can find out how much this whole thing takes up space in the RAM.
If there is a lot of bukaf
We need NoSql which is guaranteed to save data on the railway and with the possibility of easy scaling. What to take?
How to find out how much space in RAM all global variables take up in golang?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya, 2016-05-21
@VGrabko

1. if noSql is needed, then mongodb with fsync configured.
2. Calculate manually, no one knows how many characters you will allocate for the login or how many such profiles there will be in total. Well, or if "that's right now", then https://golang.org/pkg/net/http/pprof/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question