6 ms·
The performance comes from using https://github.com/valyala/fasthttp https://github.com/valyala/fasthttp instead of the stdlib net/http. From this project's FAQ
by mappu 10y ago
The performance comes from using https://github.com/valyala/fasthttp https://github.com/valyala/fasthttp instead of the stdlib net/http. From this project's FAQ:
>Why creating yet another http package instead of optimizing net/http?
Because net/http API limits many optimization opportunities.
- Bombthecat 10y agoAnd then you got your database and you speed is comparable to the rest of the world :) What I think could work is a pure in memory database with server combination. Something like redis for websites.
- Svenskunganka 10y agoI use Redis as the primary and only database. This results in quite large savings in terms of server infrastructure since memory has never been cheaper than it is today and the minimal amount of resources Redis consume in relation to the massive amount of throughput it provides. Additionally, it has data persistence reliability on par with Postgres and other battle-tested databases[0], so couldn't be happier about that. The selling point of Redis for me has been its simplicity. It has a fairly small set of features in comparison to other databases, yet extremely powerful. [0] - http://oldblog.antirez.com/post/redis-persistence-demystified.html http://oldblog.antirez.com/post/redis-persistence-demystifie...
- deleted 10y ago[deleted]
- qaq 10y ago"it has data persistence reliability on par with Postgres" if we pretend transactions do not exist and postgres is running in some non-default config then maybe, but we don't need to pretend.
- calcifer 10y agoRedis has transactions as well.
- qaq 10y agoyes and if you set appendonly yes appendfsync always you will get about +/- PG write performance without all the features Now I know 0 production projects using these Redis settings and I would argue it's not intended use of Redis same way as running PG with fsync = off is not generally what you want to use
- mbrock 10y agoWhy isn't it intended use? And are there actual problems with it even if it isn't intended use?
- jpgvm 10y agoIt's not intended use because fsyncing every write to disk makes it inferior to every datastore designed to fsync every write. See here PostgreSQL. For read performance if your dataset fits in memory PG is just as fast as Redis. The main attraction of Redis is in-memory writes with async persistence. Trading durability and availability for the increased performance. If you give up this then there is precisely 0 reasons to choose Redis over PostgreSQL.
- anarazel 10y ago> The main attraction of Redis is in-memory writes with async persistence. FWIW, you can have that in postgres as well, cf. synchronous_commit = off > Trading durability and availability for the increased performance. If you give up this then there is precisely 0 reasons to choose Redis over PostgreSQL. As a PostgreSQL developer, I'd say that performance / latency / jitter can still be reasons to choose redis over postgres. The per-read overhead in redis is often a good bit lower than in postgres, and there's less variability in response times.
- fweespeech 10y agohttps://muut.com/blog/news/april-2014-service-failure.html https://muut.com/blog/news/april-2014-service-failure.html https://muut.com/blog/technology/redis-as-primary-datastore-wtf.html https://muut.com/blog/technology/redis-as-primary-datastore-... Counter point of a real world implementation where they tried to make it the primary data store.
- Svenskunganka 10y agoHave you even read the article? This was caused by Mongo running with a wrong flag, and the authors explicitly said that their backup script only contained ONE backup. That's bad engineering, not fault with Redis. Redis is extremely safe if you configure it correctly.
- fweespeech 10y agoYes, on a small number of nodes it works in a handful of use cases. That isn't the same as it being equal and equivalent in terms of reliability at scale. They resorted to weird hack-y shit for something I use MySQL or Postgres for on a regular basis. So have most people who built stuff on Redis like this: > I use Redis as the primary and only database. > Additionally, it has data persistence reliability on par with Postgres and other battle-tested databases[0], so couldn't be happier about that.
- mtanski 10y agoredis by default does not fsync every change, instead it syncs every second. So no it's data reliability is not on par with Postgres in the default configuration.
- oceanic 10y agoMemSQL (http://www.memsql.com/community/ http://www.memsql.com/community/) might also be an interesting option to try.
- Bombthecat 10y agoWow, that looks cool. Will look into it after work :) Thanks
- brightball 10y agoLike ETS/DETS for Elixir/Erlang?
- benbjohnson 10y agoI've been using a local key/value store as my backing database and it works great. Primary key access is usually less than 1µs and net/http is typically my bottleneck. That being said, unless you're getting a massive number of requests, using a specialized HTTP library seems like overkill.
- kasey_junk 10y agoWhat do you mean by usually? What do the "bad" cases look like and how often do they happen? How are you measuring that key access and is it happening across cores? Are you setting any OS level settings around isolation?
- vardump 10y agoThe world is not only about CRUD apps with a database backend.
- fishnchips 10y agoA surprisingly large part of the world is about CRUD apps. And among the non-CRUD apps a surprisingly large part of them is still CRUD.
- valyala 10y agoThere are a plenty of in-process 'databases' for Go starting from a simple built-in map and ending with something like https://github.com/boltdb/bolt https://github.com/boltdb/bolt or even https://github.com/hashicorp/go-memdb https://github.com/hashicorp/go-memdb .
- gummiruessel 10y agoIt's worth noting that fasthttp doesn't support HTTP/2.0. According to the README, there are plans for it in the future.
- amelius 10y agoHmm, thus not so fast after all ...