Hello Jerome,
what about lua and a lua_shared_dict, warming up from redis? I am not
sure how much data a lua_shared_dict can handle, but you can find some
information about such a idea here:
http://devblog.mixlr.com/2012/09/01/nginx-lua/
Alexander
Am 13.11.2014 03:25, schrieb Vladislav Manchev:
Redis is an in-memory database already. Key-value store technically with
tons of other useful data structures and features. Saving to disk is
just a feature.
It seems you're just looking for a traditional relational database.
Postgres or MySQL can work entirely from memory too - put them on a ram
disk for example. They are supported by OpenResty pretty well I think.
Then, there's the problem of data durability, of course, so you may want
to spin up a replication server on the same machine to replicate
contents from ram disk to hard disk.
Redis is not a bad idea after all if you can model your data properly
and fit it into the data structures provided. Maybe this is your best
bet and deserves a second thought.
BTW, you don't want TCP if you want low latency/overhead -- just use
unix sockets instead.
Best,
Vladislav
On Thu, Nov 13, 2014 at 1:05 AM, Jerome Lafon <gg....@gmail.com
<mailto:gg....@gmail.com>> wrote:
Thank you for your reply
My concern is that I have around 100 000 records to store 3 times
and each record contains between 20 and 100 characters.
I though that with a real database the total weight could be really
less than with Redis. And the index building is automatic, it can
make saving some time.
I was thinking using an in memory database app like sqlite but it
seems not easy to interact with it by TCP for the non blocking behavior.
Do you any experience with voltdb database or a similar in memory
database accessible via TCP?
Jerome
Le mercredi 12 novembre 2014 21:27:20 UTC+1, agentzh a écrit :
Hello!
On Wed, Nov 12, 2014 at 10:23 AM, Jerome Lafon wrote:
> Finally each city is inserted 3 times in Redis in 3 sorted set.
> it would have been easier to use an in momory database like
sqlite with only
> one table to implement this feature without duplicating the
data.
>
Well, this is how redis works: building indexes for queries
yourself.
Maybe you can use IDs to save some storage. For a real in-memory
data
bases, the information has to be duplicated somehow as well because
they also need to build indexes to speedup things (though the
indexes
are usually built and maintained automatically).
> Do you have some ideas to improve the way to implement an
efficient
> autocomplete feature without duplicating the data like I did
it? (some redis
> tips or an efficient in memory database usable with a
lua-resty module?)
>
To embed an in-memory database directly into the nginx server, you
have to make it reside in the shm and protect it with locks so that
all the workers can access it safely. Similar to ngx_lua's
lua_shared_dict facility :)
Regards,
-agentzh.
--
Mit freundlichen Grüßen
Alexander Kunz
WISHMEDIA GmbH
Kopernikusstr. 4
D-65232 Taunusstein
http://www.wishmedia.de
Tel: +49-6128-973797
Fax: +49-6128-973798
E-Mail: ak...@wishmedia.de
Geschäftsführer: Alexander Kunz
Handelsregister: Amtsgericht Wiesbaden, HRB 24125
USt-IdNr.: DE265062989