Hello,
You should certainly be able to use asio for this, depending on the platform and how much processing you need to do apart from the FIX decode, you should see figures in the 10s-100 microsecond range.
Ideas:
1) From what you describe it sounds like the sender can't deliver the market data fast enough, causing it to queue up on their side. It might be that your receive path is not fast enough. Maybe you are doing some extra work beyond what you showed below, and that is causing the TCP receive buffer to fill up on your side and consequentially the sender to slow down? (TCP window will fill).. Try timing how long you spend from you enter the async callback until you issue the new async_read_some... You should try to get that figure down.
2) It might be a good idea to increase TCP receive buffers in case market data is bursty (boost::asio::socket_base::receive_buffer_size)
3) Only affects your sending, but make sure you disable Nagles algorithm (boost::asio::ip::tcp::no_delay option) as well.
BR,
Martin
From: Boost-users [mailto:boost-users-bounces@lists.boost.org] On Behalf Of ??
Sent: 20. oktober 2015 16:27
To: boost-users ; Boost Users
Subject: [Boost-users] what is the problem with my async_read_some function?
hi all!
i have a problem with the async_read_some function.
i code a client to connect a server, after login the server will send a lot of FAST(FIX Adapted for Streaming) Data constantly. i just use ip::tcp::socketfile:///D:\package\boost_1_58_0\doc\html\boost_asio\reference\ip__tcp\socket.html.async_read_some function to read the data from server, but the interface of the server software sometime show that there are some data package wait for send(maybe my client not receive then immidiately).but, when i use a commercial client to connect and receive data from the server, there is no data package wait for send on the server.
my code:
BODY_LEN = 1024 * 1024 * 4 //4M
boost::array body_;
void client::login_handler(const boost::system::error_code& ec, std::size_t bytes_transferred)
{
if (ec)
{
error_.code = ec.value();
strncpy(error_.msg, ec.message().c_str(), ERROR_MSG_LEN - 1);
error_.msg[ERROR_MSG_LEN - 1] = '/0';
glog.error("login_handler get an error: %s", error_.msg);
return;
}
socket_.async_read_some(boost::asio::buffer(body_),
boost::bind(&client::login_handler, this, boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred));
static bool first = true;
if (first)
{
heartbeat_inteval_ = 10;
first = false;
send_heartbeat();
}
}
there is a deadline_timer to send heartbeat to server every 10 seconds , user the same socket_ .
i user asio handler tracking to debug, and found that sometimes between the async_read_some function call and their callback function call are more than 100ms, i don't kown why becasue the server send data always, and other commercial client is ok?
@asio|1445319300.343750|25*26|socket@00840104.async_receive
@asio|1445319300.343750|<25|
@asio|1445319300.390625|>26|ec=system:0,bytes_transferred=24605
@asio|1445319300.390625|26*27|socket@00840104.async_receive
@asio|1445319300.390625|<26|
@asio|1445319300.578125|>27|ec=system:0,bytes_transferred=15805
@asio|1445319300.593750|27*28|socket@00840104.async_receive
@asio|1445319300.593750|<27|
@asio|1445319300.781250|>28|ec=system:0,bytes_transferred=3939
@asio|1445319300.781250|28*29|socket@00840104.async_receive
@asio|1445319300.781250|<28|
@asio|1445319300.781250|>29|ec=system:0,bytes_transferred=8858
@asio|1445319300.796875|29*30|socket@00840104.async_receive
@asio|1445319300.796875|<29|
@asio|1445319300.796875|>30|ec=system:0,bytes_transferred=23906
@asio|1445319300.796875|30*31|socket@00840104.async_receive
@asio|1445319300.796875|<30|
@asio|1445319300.796875|>31|ec=system:0,bytes_transferred=25124
@asio|1445319300.796875|31*32|socket@00840104.async_receive
@asio|1445319300.796875|<31|
@asio|1445319300.921875|>32|ec=system:0,bytes_transferred=18061
@asio|1445319300.937500|32*33|socket@00840104.async_receive
@asio|1445319300.937500|<32|
@asio|1445319301.125000|>33|ec=system:0,bytes_transferred=19960
@asio|1445319301.125000|33*34|socket@00840104.async_receive
@asio|1445319301.140625|<33|
@asio|1445319301.140625|>34|ec=system:0,bytes_transferred=11680
could someone give some suggest? thanks a lot!