I tried to send 10M data to cluster via JGroups by udp-multicast, it takes tens of seconds, I have changed some udp properties, but it does not work, here is my udp.xml
file. We test in local network.
there no problem while sending small data.
<UDP
singleton_name="fr_cluster_TP_UDP"
mcast_addr="${jgroups.udp.mcast_addr:235.5.5.10}"
mcast_port="${jgroups.udp.mcast_port:45588}"
ip_ttl="1"
tos="8"
ucast_recv_buf_size="5M"
ucast_send_buf_size="5M"
mcast_recv_buf_size="5M"
mcast_send_buf_size="5M"
max_bundle_size="64K"
max_bundle_timeout="30"
enable_diagnostics="true"
thread_naming_pattern="cl"
timer_type="new3"
timer.min_threads="2"
timer.max_threads="4"
timer.keep_alive_time="3000"
timer.queue_max_size="500"
thread_pool.enabled="true"
thread_pool.min_threads="2"
thread_pool.max_threads="8"
thread_pool.keep_alive_time="5000"
thread_pool.queue_enabled="true"
thread_pool.queue_max_size="10000"
thread_pool.rejection_policy="discard"
oob_thread_pool.enabled="true"
oob_thread_pool.min_threads="1"
oob_thread_pool.max_threads="8"
oob_thread_pool.keep_alive_time="5000"
oob_thread_pool.queue_enabled="false"
oob_thread_pool.queue_max_size="100"
oob_thread_pool.rejection_policy="discard"/>
<PING/>
<MERGE3 max_interval="30000"
min_interval="10000"/>
<FD_SOCK/>
<FD_ALL/>
<VERIFY_SUSPECT timeout="1500"/>
<BARRIER/>
<pbcast.NAKACK2 xmit_interval="500"
xmit_table_num_rows="100"
xmit_table_msgs_per_row="2000"
xmit_table_max_compaction_time="30000"
max_msg_batch_size="500"
use_mcast_xmit="false"
discard_delivered_msgs="true"/>
<UNICAST3 xmit_interval="500"
xmit_table_num_rows="100"
xmit_table_msgs_per_row="2000"
xmit_table_max_compaction_time="60000"
conn_expiry_timeout="0"
max_msg_batch_size="500"/>
<pbcast.STABLE stability_delay="1" desired_avg_gossip="50000"
max_bytes="4M"/>
<pbcast.GMS print_local_addr="true" join_timeout="2000"
view_bundling="true"/>
<FRAG2 frag_size="60K"/>
<RSVP resend_interval="2000" timeout="10000"/>
<pbcast.STATE_TRANSFER/>
<!-- pbcast.FLUSH /-->
ANYONE have handled problem like this, I am doubting it's caused by local udp configuration instead of udp.xml
file.
My demo is :
public static void main(String[] args) throws Exception {
JChannel jChannel = new JChannel(IOUtils.getResourceAsStream("/com/fr/cluster/engine/core/context/protocol/udp.xml", Test.class));
jChannel.connect("testing----");
jChannel.setDiscardOwnMessages(true);
jChannel.setReceiver(new ReceiverAdapter() {
public void receive(Message msg) {
long current = System.currentTimeMillis();
System.out.println(new SimpleDateFormat("HH:mm:ss.sss").format(new Date(current)) + " msg received. size : " + msg.getLength());
}
});
Message message = new Message(null, getBytes());
while (true) {
System.in.read();
System.out.println("Message sending.....");
long current = System.currentTimeMillis();
jChannel.send(new Message(null, new SimpleDateFormat("HH:mm:ss.sss").format(new Date(current))));
jChannel.send(message);
System.out.println("Message send complete.Time used " + (System.currentTimeMillis() - current));
}
}
private static byte[] getBytes() throws FileNotFoundException {
//10M
int len = 10 * 1024 * 1024;
byte[] data = new byte[len];
for (int i = 0; i < len; i++) {
data[i] = 1;
}
return data;
}
答案 0 :(得分:0)
你有一个我可以看一下的示例程序吗?
我进行了快速测试,并向一名成员发送了10MB,花了97ms ...
请注意,在您的配置中,您的线程池中最多只能运行2个线程,因为您已启用队列且其大小为10000.这可能会减慢速度...尝试禁用队列并提升{{ 1}}。
答案 1 :(得分:0)
你犯了一个经典错误:你重用了message
[1]!如果您快速连续发送邮件,这将不起作用。将message
的创建移动到循环中,每次迭代创建一条消息,然后这将有效。
我在3.6和4.x中尝试了这一点并且它运行得很好。