High Performance Erlang Kafka Producer
- Compression support (snappy)
- Performance optimized
- Topic buffering (delay, size)
Name | Type | Default | Description |
---|---|---|---|
broker_bootstrap_servers | [{inet:ip_address() | inet:hostname(), inet:port_number()}] | [{"127.0.0.1", 9092}] | Bootstrap servers used to query topic metadata |
broker_pool_size | pos_integer() | 2 | Number of connections per broker |
broker_pool_strategy | random | round_robin | random | Broker connection selection strategy |
broker_reconnect | boolean() | true | Reconnect closed broker connections |
broker_reconnect_time_max | pos_integer() | infinity | 120000 | Maximum reconnect time (milliseconds) |
broker_reconnect_time_min | non_neg_integer() | 0 | Minimum reconnect time (milliseconds) |
Name | Type | Default | Description |
---|---|---|---|
acks | 0..65535 | 1 | Number of acknowledgements required for a succeful produce |
buffer_delay | pos_integer() | 1000 | Maximun delay (milliseconds) before flushing the buffer |
buffer_size | pos_integer() | 10000 | Maximun buffer size (bytes) before flushing |
compression | none | snappy | snappy | Compression configuration |
metadata_delay | pos_integer() | 60000 | Maximun delay (milliseconds) before reloading metadata |
pool_size | pos_integer() | 2 | Number of topic buffer proccesses |
1> flare_app:start().
{ok,[shackle,flare]}
2> TopicOpts = [{acks, 1}, {compression, snappy}, {buffer_size, 1000000}, {pool_size, 8}].
[{acks,1},
{compression,snappy},
{buffer_size,1000000},
{pool_size,8}]
3> flare_topic:start(<<"my topic">>, TopicOpts).
ok
4> flare:produce(<<"my topic">>, <<"my msg">>).
ok
5> {ok, ReqId} = flare:async_produce(<<"test">>, <<"hello">>).
{ok,{{1468,419385,705022},<0.146.0>}}
6> flare:receive_response(ReqId).
ok
7> flare_topic:stop(<<"my topic">>).
ok
make dialyzer
make elvis
make eunit
make xref
To run the profile target you must first start kafka:
./bin/zookeeper-server-start.sh config/zookeeper.properties &
./bin/kafka-server-start.sh config/server.properties &
Then you can run the profile target:
make profile
The MIT License (MIT)
Copyright (c) 2016 Louis-Philippe Gauthier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.