Giter VIP home page Giter VIP logo

kyoto's Introduction

Kyoto Tycoon

Kyoto Tycoon is a lightweight network server on top of the Kyoto Cabinet key-value database, built for high-performance and concurrency. Some of its features include:

  • master-slave and master-master replication
  • in-memory and persistent databases (with optional binary logging)
  • hash and tree-based database formats (with optional compression)
  • server-side scripting in Lua (API)

It has its own fully-featured protocol based on HTTP and a (limited) binary protocol for even better performance. There are several client libraries implementing them for multiple languages (we're maintaining one for Python here).

It can also be configured with simultaneous support for the memcached protocol, with some limitations on available data update commands. This is useful if you wish to replace memcached in larger-than-memory/persistency scenarios.

Example Architecture

What's this fork?

The development of Kyoto Tycoon and Kyoto Cabinet by their original authors at FAL Labs seems to have halted around 2012. The software works as advertised and is very reliable, which may explain the lack of activity, but the unmodified upstream sources fail to build in recent operating system releases (with recent compilers).

We at Altice Labs (previously at SAPO) intend this repository to be a place to keep readily usable (but conservative) versions for modern machines. Nevertheless, pull requests containing bug fixes or new features are welcome.

What's included?

Here you can find improved versions of the latest available upstream releases, intended to be used together and tested in real-world production environments. The changes include bug fixes, minor new features and packaging for a few Linux distributions.

Check our stable release history to see what's new.

Supported Platforms

Our primary target platform for these packages is Linux (64-bit). Mostly Debian and CentOS, but we've also done some testing on non-Linux platforms such as FreeBSD and MacOS X.

The upstream sources claim to support additional platforms, but we haven't got around to test them for ourselves (yet). If you do, let us know.

Installing

Download our latest stable source release or clone the repository from GitHub. Then, to build and install the Kyoto Cabinet library and the Kyoto Tycoon server in one go, run:

$ make PREFIX=/usr/local
$ sudo make install

Notes:

  • Make sure you have zlib, lzo and Lua 5.1.x already installed;
  • The installation root directory (PREFIX) is optional. By default it already installs into /usr/local;
  • If you're building on FreeBSD, use gmake from the ports collection instead of standard make.

Packaging

Instead of installing directly from source, you can optionally build packages for one of the Linux distributions listed below. If you distribution of choice doesn't happen to be supported, patches are always welcome.

On Debian, build a binary .deb package (into the ./build directory) by running:

$ make deb

On Red Hat Linux (or a derivative such as CentOS), build both source and binary .rpm packages (into the $HOME/rpmbuild directory) by running:

$ make rpm
$ make rpm-selinux  # (optional) builds an extra package containing a hardened SELinux policy

Besides being cleaner and more maintainable than installing directly from source, these packages also register init scripts to run the server with minimal privileges and install configuration files pre-filled with some examples.

Running

If there's a place in need of improvement it's the documentation for the available server options in Kyoto Tycoon. Make sure to check the command-line reference to understand what each option means and how it affects performance vs. data protection. But you may want to try this as a quick start for realistic use:

$ /usr/local/bin/ktserver -ls -th 16 -port 1978 -pid /data/kyoto/kyoto.pid \
                          -log /data/kyoto/ktserver.log -oat -uasi 10 -asi 10 -ash \
                          -sid 1001 -ulog /data/kyoto/db -ulim 104857600 \
                          '/data/kyoto/db/db.kct#opts=c#pccap=256m#dfunit=8'

This will start a standalone server using a persistent B-tree database with compression (opts=c) and binary logging enabled. The pccap=256m option increases the default page cache memory to 256MB.

The data durability options (-oat, -uasi, -asi, -ash) have a significant performance impact and you may want to consider leaving them out if you're storing volatile data (which is the main use case for Kyoto Tycoon anyway).

If you have an idea of how many objects you'll be storing, you can use a persistent hash database instead:

$ /usr/local/bin/ktserver -ls -th 16 -port 1978 -pid /data/kyoto/kyoto.pid \
                          -log /data/kyoto/ktserver.log -oat -uasi 10 -asi 10 -ash \
                          -sid 1001 -ulog /data/kyoto/db -ulim 104857600 \
                          '/data/kyoto/db/db.kch#opts=l#bnum=1000000#msiz=256m#dfunit=8'

In this case bnum=1000000 configures 1 million hash buckets (should be set to about twice the number of expected keys) and msiz=256m sets the size of the memory mapped region (larger is better, provided you have enough RAM). Like the B-tree database above, performance considerations about data durability options also apply here.

Another example, this time for an in-memory cache hash database limited to 256MB of stored data (LRU-based):

$ /usr/local/bin/ktserver -log /var/log/ktserver.log -ls '*#bnum=100000#capsiz=256m'

To enable simultaneous support for the memcached protocol, use the -plsv and -plex parameters. The previous example would then become:

$ /usr/local/bin/ktserver -log /var/log/ktserver.log -ls \
                          -plsv /usr/local/libexec/ktplugservmemc.so \
                          -plex 'port=11211#opts=f' \
                          '*#bnum=100000#capsiz=256m'

The opts=f parameter enables flags support for the memcached protocol. These are stored by Kyoto Tycoon as the last 4 bytes of the value, which means some care must be taken when mixing protocols (our python library can handle this for you, for example).

Caveats

Based on our experience, you should consider a few things when using Kyoto Tycoon in production:

  • Don't use the capsiz option with on-disk databases as the server will temporarily stop responding to free up space when the maximum capacity is reached. In this case, try to keep the database size under control using auto-expiring keys instead.

  • On-disk databases are sensitive to disk write performance (impacting record updates as well as reads). Enabling transactions and/or synchronization makes this worse, as does increasing the number of buckets for hash databases (larger structures to write). Having a disk controller with some kind of battery-backed write-cache makes these issues mute.

  • Choose your on-disk database tuning options carefully and don't tune unless you need to. Some options can be modified by a simple restart of the server (eg. pccap, msiz) but others require creating the database from scratch (eg. bnum, opts=c).

  • Make sure you have enough disk space to store your on-disk databases as they grow. The server uses mmap() for file access and handles out-of-space conditions by terminating immediately. The database should still be consistent if this happens, so don't fret too much about it.

  • The unique server ID (-sid) is used to break replication loops (a server instance ignores keys with its own SID). Keep this in mind when restoring failed master-master instances. The documentation recommends always choosing a new SID but this doesn't seem a good idea in this case. If the existing master still has keys from the failed master with the old SID pending replication, the new master with a new SID will propagate them back.

Build Status

kyoto's People

Contributors

car3ca avatar carlosefr avatar danifbento avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kyoto's Issues

About comparing a record's key with input key

Hi, everyone
I've read source code kyotocabinet-1.2.79 recently, and there is a piece of code (at line 1936 file kcdirdb.h) that I can't clearly understand.

bool accept_impl(const char* kbuf, size_t ksiz, Visitor* visitor, const char* name) {
    _assert_(kbuf && ksiz <= MEMMAXSIZ && visitor && name);
    bool err = false;
    const std::string& rpath = path_ + File::PATHCHR + name;
    Record rec;
    if (read_record(rpath, &rec)) {
      if (rec.ksiz == ksiz || !std::memcmp(rec.kbuf, kbuf, ksiz)) {
        if (!accept_visit_full(kbuf, ksiz, rec.vbuf, rec.vsiz, rec.rsiz,
                               visitor, rpath, name)) err = true;
      } else {
        set_error(_KCCODELINE_, Error::LOGIC, "collision of the hash values");
        err = true;
      }
      delete[] rec.rbuf;
    } else {
      if (!accept_visit_empty(kbuf, ksiz, visitor, rpath, name)) err = true;
    }
    return !err;
  }

The code that compares input key with record's key: rec.ksiz == ksiz || !std::memcmp(rec.kbuf, kbuf, ksiz)
I think it must be something looks like: rec.ksiz == ksiz && !std::memcmp(rec.kbuf, kbuf, ksiz).
Thank you for reading my issue.

Lua error

Hi, I already had zlib, lzo installed before by the admins, and installed Lua 5.1, but not in /usr/local/lib/ .
I downloaded kyoto, but when I do 'make' , it errors out with :
checking kccommon.h usability... yes
checking kccommon.h presence... yes
checking for kccommon.h... yes
checking lua.h usability... no
checking lua.h presence... no
checking for lua.h... no
configure: error: lua.h is required
make: *** [kyototycoon/Makefile] Error 1

how do I let the Makefile know where to look for lua (i.e not in /usr/local/lib/ ) ?

Compiling with Lua in non-standard location

Hello,

I'm trying to compile KyotoTycoon without root access, using conda to install dependencies.

I've installed Lua in a non-default location, and now simply cannot find a way to add it to the Makefile/config - compilation always fails after failing to find lua.h

Any tips? Thank you in advance

Fails to build on Slackware64 14.2

Hi there

I discovered a build bug when compiling under Slackware64 14.2

The build failed with:

g++ -g -O2 -Wall -fPIC -fsigned-char -g0 -O2 -Wno-unused-but-set-variable -Wno-unused-but-set-parameter -o ktserver ktserver.o myscript.o \
  -L. -L/pkg/kyototycoon-al/20170410/lib -L/usr/local/lib -L/usr/local/lib/lua -L/pkg/kyotocabinet-al/20170410/lib -L/pkg/lua/5.1.5/lib -Wl,-rpath-link,.:/usr/local/lib:.:/usr/local/lib::/usr/local/lib/lua:/pkg/kyotocabinet-al/20170410/lib:/pkg/lua/5.1.5/lib -Wl,--as-needed  -lkyototycoon -lkyotocabinet -llua
/usr/lib64/gcc/x86_64-slackware-linux/5.3.0/../../../../x86_64-slackware-linux/bin/ld: /pkg/lua/5.1.5/lib/liblua.a(loadlib.o): undefined reference to symbol 'dlclose@@GLIBC_2.2.5'
/lib64/libdl.so.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Makefile:535: recipe for target 'ktserver' failed

So, searching the web for:

"liblua.a(loadlib.o): undefined reference to symbol 'dlclose@@GLIBC_2.2.5'"

... led me to this link

... which states:

-ldl where dlclose@@GLIBC_2.2.5 should be after -llua, where this symbol is used.

So I patched the Makefile as follows to correct the issue:

cd /path/to/kyoto/kyototycoon
sed -i 's/CMDLIBS =  -lkyotocabinet -llua/CMDLIBS =  -lkyotocabinet -llua -ldl/' Makefile

Kyotocabinet make error

Hi,

I'm trying to compile kyoto. All dependencies are installed. Unfortunately the configure cannot find the lzo libraries with I linked in LD_LIBRARY_PATH, C_INCLUDE_PATH, LD_RUN_PATH and LIBRARY_PAT.

checking for zlib.h... yes
checking lzo/lzo1x.h usability... no
checking lzo/lzo1x.h presence... no
checking for lzo/lzo1x.h... no
configure: error: lzo/lzo1x.h is required
make: *** [kyotocabinet/Makefile] Error 1

How do I solve this?

Thanks a lot
F

configure: error: lzo/lzo1x.h is required

Hello,

How to specified zlib, lzo and Lua 5.1.x path with make build?

I tried below looks like does not work

export LZO_INC="/usr/local/proxy/lzo2.10/include"
export LZO_LIB="/usr/local/proxy/lzo2.10/lib"

it is not a issue - but gratitude

very pleased that KT is not thrown. This is a really unique program - very fast and consumes little memory. It works on the server for more than 8 years without a single error. Unfortunately, such software like this are few. is in fashion java-monsters

Still maintained ?

Is this fork still being maintained, there seems to be no updates since 2017.

Replication is not working

Create master Node for Kyoto Tycoon with file database
Start pushing data to it
After around 10 Million keys are pushed to it, start a slave to this master node
Slave does not sync the 10M keys already pushed to it, though it does have newly added keys.

Fails to build on Slackware64 14.1

Hello

Firstly, thanks for sharing your additions to FAL Labs' work on Kyto Cabinet and Tycoon.

I'm unable to build master (commit 87287b8) on Slackware64 14.1.

GCC 4.8.2
GLIBC 2.17

Firstly, I had to patch your Makefile to permit custom Lua installation paths:

--- kyoto-87287b8/Makefile  2016-03-29 16:39:20.000000000 +0000
+++ kyoto-patched/Makefile  2016-05-13 19:04:07.092561610 +0000
@@ -7,6 +7,7 @@
 DESTDIR =
 OS := $(shell uname -s)
 NPROCS = 1
+LUA_ROOT ?= /usr
 CONFIG_FLAGS =


@@ -55,7 +56,7 @@
    $(eval CABINET_ROOT := $(shell awk '/^prefix *=/ {print $$3}' kyotocabinet/Makefile))
    test -x kyototycoon/configure && cd kyototycoon && \
    PKG_CONFIG_PATH="../kyotocabinet" CPPFLAGS="-I../kyotocabinet" LDFLAGS="-L../kyotocabinet" \
-   ./configure --prefix="$(PREFIX)" --with-kc="$(CABINET_ROOT)" --enable-lua $(CONFIG_FLAGS)
+   ./configure --prefix="$(PREFIX)" --with-kc="$(CABINET_ROOT)" --enable-lua --with-lua="$(LUA_ROOT)" $(CONFIG_FLAGS)

 tycoon: kyototycoon/Makefile
    $(MAKE) -j$(NPROCS) -C kyototycoon

It would be a welcome addition to your Makefile.

Then, an attempt to build with:

make PREFIX=/pkg/kyoto/20160329 LUA_ROOT=/pkg/lua/5.1.5

Ended in failure, as follows:

  -L../kyotocabinet -L. -L/pkg/kyoto/20160329/lib -L/usr/local/lib -L/pkg/kyoto/20160329/lib -L/pkg/lua/5.1.5/lib -Wl,-rpath-link,.:/usr/local/lib:.:/usr/local/lib::/pkg/kyoto/20160329/lib:/pkg/lua/5.1.5/lib -Wl,--as-needed  -lkyototycoon -lkyotocabinet -llua
/usr/lib64/gcc/x86_64-slackware-linux/4.8.2/../../../../x86_64-slackware-linux/bin/ld: /pkg/lua/5.1.5/lib/liblua.a(loadlib.o): undefined reference to symbol 'dlclose@@GLIBC_2.2.5'
/usr/lib64/gcc/x86_64-slackware-linux/4.8.2/../../../../x86_64-slackware-linux/bin/ld: note: 'dlclose@@GLIBC_2.2.5' is defined in DSO /lib64/libdl.so.2 so try adding it to the linker command line
/lib64/libdl.so.2: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status
make[1]: *** [ktserver] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory `/home/admin/src/kyoto-master/kyototycoon'
make: *** [tycoon] Error 2

I'd greatly appreciate it if you'd help troubleshoot this build.

Let me know if you require further information.

Thanks.

Snapshotting malfunctioning

Whenever I try to have ktserver create a snapshot after its run, ktserver completes normaly but does not create a snapshot. When I delved a bit further, and modified a bit the code to provide the error message, I got this:

2017-11-29T12:57:28.292423Z: [ERROR]: database error: 8: logical inconsistency: hanging

Is there any particular reason this should be happening? I have tried with multiple versions from this repository and the CloudFlare version, to no avail.

Command lines are as follows:

$ ktserver -port 27732 -ls -tout 200000 -th 64 -bgs /tmp/kt/snapshot -bgsc lzo -bgsi 1000000 -log /tmp/kt/log :#opts=ls#bnum=30m#msiz=50g#ktopts=p &
$ ktremotemgr set -host localhost -port 27732 japan tokyo
$ ktremotemgr get -host localhost -port 27732 japan
tokyo
$ kill -SIGINT $(pgrep ktserver)

Thank you for your kind help.

compile error

I am trying to compile kyoto at our cluster. I finished libkyotocabinet.so but get error when compile kyototycoon:

/xx/software/bin/gcc -g -O2 -Wall -ansi -pedantic -fPIC -fsigned-char -g0 -O2 -Wno-unused-but-set-variable -Wno-unused-but-set-parameter -o kclangctest kclangctest.o -L. -L/xx/software/lib -L/usr/local/lib -Wl,-rpath-link,.:/usr/local/lib:.:/usr/local/lib:/lib:/lib64:/usr/lib:/usr/lib64:/xx/software/lib:/xx/software/lib64:/opt/gridengine/lib/lx-amd64:/opt/openmpi/lib:/opt/python/lib:/xx/software/tools/instantclient_12_2/ -Wl,--as-needed -lkyotocabinet
./libkyotocabinet.so: undefined reference to std::__detail::_List_node_base::_M_unhook()@GLIBCXX_3.4.15' ./libkyotocabinet.so: undefined reference to std::__detail::_List_node_base::_M_hook(std::__detail::_List_node_base*)@GLIBCXX_3.4.15'

I have checked my libstdc++ and other linked library and they all have no related to GLIBCXX_3.4.15
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.