tidwall / summitdb

In-memory NoSQL database with ACID transactions, Raft consensus, and Redis API
Other
1.41k stars 78 forks source link

HTTP 307 Code when Follower Command Submit #3

Closed ejemba closed 7 years ago

ejemba commented 7 years ago

Hi first of all thank you for this clean, efficient distributed db !

I was wondering if a standard redirection can not be applied in the case where a follower receive a command submit. Like the following I saw Sample in rqlite . The follower in this case redirect to the leader using a 307 code.

This way even tools like curl, wget would understand, and the dev experience would increase.

What do you think ?

tidwall commented 7 years ago

Hi @ejemba,

Currently only leaders can accept most commands. When a command is send to a follower the client will receive:

-TRY 127.0.0.1:7481

Which tells the client to try the command on the other server.

It's possible that we could have a follower proxy the command to the leader. This is something that I've considered, but I've held off on adding this functionality because it would increase the network chatter between the servers. I think it's preferable to have the client keep track of the leader by switching servers automatically whenever a -TRY message is received. Leadership changes are not an often occurrence.

Right now SummitDB uses the Redis protocol, not HTTP for client->server communication. Tools like redis-cli, telnet, or nc can be used to send commands from the shell. To execute commands through a shell you could:

echo PING | nc localhost 7481

I hope this information is helpful and thanks for your interest in the project.

ejemba commented 7 years ago

@tidwall yes the information was helpful. I did not know for the redis protocol.

thanks.

I think use summitdb as a light eventstore thanks to the sort keys feature of buntdb.