【Hacker News搬运】Redis用SQLite重新实现
-
Title: Redis re-implemented with SQLite
Redis用SQLite重新实现
Text:
Url: https://github.com/nalgeon/redka
很抱歉,看起来在尝试使用 webscraper 工具抓取指定 URL 时出现了错误。错误信息表明连接被远程端关闭了,这可能是因为请求没有被正确处理或者服务器拒绝了请求。由于我无法直接访问网络来查看内容,因此无法直接翻译或分析页面内容。如果您能够提供页面的内容或者具体的请求信息,我可以尝试帮助您进行分析和总结。
Post by: tosh
Comments:
jitl: I’m not sure to what degree you want to follow the Redis no concurrency “everything serialized on one thread” model.<p>You can get substantially better performance out of sqlite by using the lower level <a href="https://github.com/crawshaw/sqlite">https://github.com/crawshaw/sqlite</a>, turning on WAL etc, using a connection per goroutine for reads, and sending batches of writes over a buffered channel / queue to a dedicated writer thread. That way you can turn off SQLite’s built in per-connection mutex but still be thread safe since each connection is only used on a single thread at a time.<p>For this use-case you will also probably save a lot of time if you use some large arena-style buffers (probably N per conn?) and copy incoming parameter bytes from the network request/socket to the buffer, or copy straight from sqlite out to the socket, instead of allocating and passing around a bunch of individual strings. Boxing those strings in interface{} (as done by the high level sql stdlib) slows things down even more.<p>None of this is necessary to get usable perf, even decently good perf, just sharing some tips from my experience trying to get absolutely maximum write throughput from SQLite in Golang.
jitl: 我不确定你想在多大程度上遵循Redis无并发“一个线程上序列化的一切”模型<p> 您可以通过使用较低级别的<a href=“https://;/;github.com/!crawshaw/:sqlite”>https://从sqlite获得更好的性能/;github.com/;克劳肖;sqlite</a>,打开WAL等,使用每个goroutine的连接进行读取,并通过缓冲通道发送批量写入;队列到专用的编写器线程。这样,您可以关闭SQLite内置的每个连接互斥,但仍然是线程安全的,因为每个连接一次只能在单个线程上使用<p> 对于这个用例,如果您使用一些大型竞技场式缓冲区(可能为N per conn?)并从网络请求中复制传入的参数字节,您也可能会节省大量时间;socket到缓冲区,或者直接从sqlite复制到socket,而不是分配和传递一堆单独的字符串。在接口{}中对这些字符串进行装箱(正如高级sqlstdlib所做的那样)会进一步减慢速度<p> 这些都不是获得可用性能所必需的,即使是相当好的性能,只是分享了我在Golang中尝试从SQLite获得绝对最大写入吞吐量的经验中的一些技巧。
nalgeon: I'm a big fan of both Redis and SQLite, so I decided to combine the two. SQLite is specifically designed for many small queries[1], and it's probably as close as relational engines can get to Redis, so I think it might be a good fit.<p>[1]: <a href="https://sqlite.org/np1queryprob.html" rel="nofollow">https://sqlite.org/np1queryprob.html</a>
nalgeon: I-;我是Redis和SQLite的忠实粉丝,所以我决定将两者结合起来。SQLite是专门为许多小型查询设计的[1];s可能是关系引擎最接近Redis的地方,所以我认为它可能很适合<p> [1]:<a href=“https://;#x2F;sqlite.org/;np1queryprob.html”rel=“nofollow”>https:///;sqlite.org/;np1queryprob.html</a>
akie: I would love to have a Redis alternative where I don't have to think about whether or not the dataset fits into memory.
akie: 我很想有一个Redis的替代品,在那里我不;不必考虑数据集是否适合内存。
TimTheTinker: I'm waiting for someone to implement the Redis API by swapping out the state machine in TigerBeetle (which was built modularly such that the state machine can be swapped out).<p><a href="https://tigerbeetle.com/" rel="nofollow">https://tigerbeetle.com/</a>
TimTheTinker: I-;我正在等待有人通过交换TigerBeetle中的状态机来实现Redis API(该状态机是模块化构建的,可以交换状态机)<p> <a href=“https://;/;tigerbeetle.com/”rel=“nofollow”>https:///;tigerbeetle.com/</一
kiitos: The entire value proposition of Redis is that it operates out of memory, and therefore has memory-like performance. (edit: And doesn't provide the benefit of, and therefore pay the costs related to, ACID-like consistency guarantees.) If you move it to disk (edit: Or try to assert ACID-like consistency or transactional guarantees) there's little reason to use Redis any more.
kiitos: Redis的整个价值主张是,它在内存不足的情况下运行,因此具有类似内存的性能。(编辑:并且不提供类似ACID的一致性保证的好处,因此也不支付与之相关的成本;没有什么理由再使用Redis了。