{"id":19431149,"url":"https://github.com/recoilme/b52","last_synced_at":"2026-01-25T00:32:13.902Z","repository":{"id":53809611,"uuid":"212128349","full_name":"recoilme/b52","owner":"recoilme","description":"b52 is a fast experimental Key/value database. With support for the memcache protocol.","archived":false,"fork":false,"pushed_at":"2023-07-27T13:06:46.000Z","size":7778,"stargazers_count":33,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-24T18:51:08.423Z","etag":null,"topics":["database","evio","freecache","key-value","memcache-protocol","memcached","sniper"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/recoilme.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-10-01T15:14:12.000Z","updated_at":"2024-11-24T22:55:30.000Z","dependencies_parsed_at":"2024-06-19T05:31:00.316Z","dependency_job_id":null,"html_url":"https://github.com/recoilme/b52","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/recoilme/b52","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/recoilme%2Fb52","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/recoilme%2Fb52/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/recoilme%2Fb52/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/recoilme%2Fb52/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/recoilme","download_url":"https://codeload.github.com/recoilme/b52/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/recoilme%2Fb52/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28739871,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-24T22:12:27.248Z","status":"ssl_error","status_checked_at":"2026-01-24T22:12:10.529Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","evio","freecache","key-value","memcache-protocol","memcached","sniper"],"created_at":"2024-11-10T14:28:24.179Z","updated_at":"2026-01-25T00:32:13.881Z","avatar_url":"https://github.com/recoilme.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\n\u003cp align=\"center\"\u003e\n\u003cimg \n    src=\"https://upload.wikimedia.org/wikipedia/commons/3/3a/Cocktail_B52.jpg\" \n    width=\"128\" height=\"200\" border=\"0\" alt=\"b-52\"\u003e\n    \u003cbr\u003e\n    b52\n\u003c/p\u003e\n\n\n[![GoDoc](https://img.shields.io/badge/api-reference-blue.svg?style=flat-square)](https://godoc.org/github.com/recoilme/b52)\n\nb52 is a fast experimental Key/value database. With support for the memcache protocol.\n\n\n# Getting Started\n\n## Installing\n\nTo start using `b52`, install Go and run `go get`:\n\n```sh\n$ go get -u github.com/recoilme/b52\n$ go build or go install\n```\n\nThis will retrieve and build the server. Or grab compiled binary version.\n\n## Starting\n\nUse `./b52 --help` for full list of params. Example:\n\n```sh\n./b52 -p 11212 -params \"sizelru=10\u0026sizettl=10\u0026dbdir=\"\n# Start server on port 11212 with 10Mb lru and ttl cache size, without persistent database.\n```\n\nor just ./b52 - for start with default params\n\n## How it work\n\n`b52` is a layered database composed of a sniper, evio and freecache.\nWhen b52 prepared properly, the ingredients separate into three distinctly visible layers.\n\nIt use [evio](https://github.com/tidwall/evio) for network communications.\n\n[sniper](https://github.com/recoilme/sniper) - [fast](https://github.com/recoilme/sniper#performance), persistant on disk storage\n\n[freecache](https://github.com/coocood/freecache) - in memory, [with zero GC overhead](https://github.com/coocood/freecache#features) cache, for keys with TTL (time to live) and LRU cache\n\n\n### The balance between speed and efficiency is achieved as follows:\n\nNew entries go to disk (sniper). As you access them, they are cached in the LRU-cache (freecache). Life-limited records are stored separately, in freecache (without persistance storage).\n\n## Memory usage\n\nFor minimizing GC and allocations overhead - Sniper stored keys, and value addres/size in plain hash (map[uint32]uint32). HashMaps are fast, but has a memory cost. You must have 2Gb+ memory for storing every 100_000_000 entrys.\n\nIn Freecache memory is preallocated and it's size depends from you. \n\n## Disk usage\n\nSniper has a minimum 8 byte overhead on every entry. But it allocate space in power of 2, and try to reuse space, if value grow. Also, sniper will try to reuse space from deleted/evicted records.\n\n## Telnet example\n\n```\ntelnet localhost 11211\nset a 0 0 5\n12345\nSTORED\nget a\nVALUE a 0 5\n12345\nEND\nclose\n```\n\n## Memcache protocol\n\nb52 use text version of [memcache protocol](https://github.com/memcached/memcached/blob/master/doc/protocol.txt). With this commands:\n```\n\tcmdAdd       = []byte(\"add\")\n\tcmdReplace   = []byte(\"replace\")\n\tcmdSet       = []byte(\"set\")\n\tcmdGet       = []byte(\"get\")\n\tcmdGets      = []byte(\"gets\")\n\tcmdClose     = []byte(\"close\")\n\tcmdDelete    = []byte(\"delete\")\n\tcmdIncr      = []byte(\"incr\")\n\tcmdDecr      = []byte(\"decr\")\n\tcmdStats     = []byte(\"stats\")\n\tcmdQuit      = []byte(\"quit\")\n\tcmdVersion   = []byte(\"version\")\n```\n\n## mc-benchmark\n\n[mc-benchmark](https://github.com/antirez/mc-benchmark)\n\n```\nDatabase params (running as master/slave, 1Gb lru cache, 100 Mb ttl cache, stats after 3 days using):\nstats\nSTAT version 0.1.3\nbytes 2301825272\nheap_sys_mb 2103\ncurr_items 17165174\ncmd_get 6660544669\ncmd_set 6494641380\nfile_size 14172392544\n\ntest (on production, with ~2k active connections at same time):\n./mc-benchmark -p 11222\n\n====== SET ======\n  10000 requests completed in 0.10 seconds\n  50 parallel clients\n  3 bytes payload\n  keep alive: 1\n\n56.39% \u003c= 0 milliseconds\n95.39% \u003c= 1 milliseconds\n100.00% \u003c= 2 milliseconds\n101010.10 requests per second\n\n====== GET ======\n  10014 requests completed in 0.08 seconds\n  50 parallel clients\n  3 bytes payload\n  keep alive: 1\n\n60.25% \u003c= 0 milliseconds\n100.00% \u003c= 1 milliseconds\n123629.63 requests per second\n\n./mc-benchmark -n 100000 -p 11212\n====== SET ======\n  100003 requests completed in 1.03 seconds\n  50 parallel clients\n  3 bytes payload\n  keep alive: 1\n\n49.59% \u003c= 0 milliseconds\n99.16% \u003c= 1 milliseconds\n100.00% \u003c= 2 milliseconds\n96996.12 requests per second\n\n====== GET ======\n  100018 requests completed in 0.98 seconds\n  50 parallel clients\n  3 bytes payload\n  keep alive: 1\n\n51.55% \u003c= 0 milliseconds\n99.72% \u003c= 1 milliseconds\n99.99% \u003c= 2 milliseconds\n100.00% \u003c= 3 milliseconds\n101851.33 requests per second\n\n```\n\n[expvar](https://gist.github.com/recoilme/0624cd5ecda195c804b67b1d64394603)\n\n## Contact\n\nVadim Kulibaba [@recoilme](https://github.com/recoilme)\n\n## License\n\n`b52` source code is available under the MIT [License](/LICENSE).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frecoilme%2Fb52","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frecoilme%2Fb52","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frecoilme%2Fb52/lists"}