Last active
June 15, 2018 06:50
-
-
Save UA3MQJ/7706a8f24b0930a8428cc5a88ded346b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Сделал модуль | |
defmodule Tm do | |
def test(x) do | |
x + 1 | |
end | |
end | |
запуск ноды iex --sname ui | |
второй ноды на том же хосте iex --sname ui2 | |
запуск ноды на другом хосте - так же | |
загрузка кода модуля в вм: | |
Code.load_file("tm.ex") | |
Tm.test(1) | |
подсоединить ноду одну к другой :net_kernel.connect_node(:ui@free) | |
должны быть одинаковые cookies | |
Варианты потестить: | |
:timer.tc(fn -> Enum.each(1..1000_000, fn(x)-> :rpc.call(:ui@free, Tm, :test, [x]) end) end) | |
:timer.tc(fn -> 1..1_000 |> Enum.map(fn(x)-> :rpc.async_call(:ui@free, Tm, :test, [x]) end) |> Enum.map(fn(x)-> :rpc.yield(x) end) end) | |
синхронный | |
:timer.tc(fn -> | |
1..100_000 |> Enum.map(fn(x) -> | |
Task.async(fn() -> | |
:rpc.call(:ui@free, Tm, :test, [x]) | |
end) | |
end) \ | |
|> Enum.each(fn(task) -> | |
Task.await(task, :infinity) | |
end) \ | |
end) | |
асинк | |
:timer.tc(fn -> | |
1..100_000 |> Enum.map(fn(x) -> | |
Task.async(fn() -> | |
:rpc.async_call(:ui@free, Tm, :test, [x]) |> :rpc.yield() | |
end) | |
end) \ | |
|> Enum.each(fn(task) -> | |
Task.await(task, :infinity) | |
end) \ | |
end) | |
ЖЕЛЕЗО | |
Серверный хост: | |
hw.model: AMD Athlon(tm) II X2 250 Processor | |
hw.machine: amd64 | |
hw.ncpu: 2 | |
Клиентский хост: OrangePI | |
Сеть - проводная 100 мегабит. Обе машины напрямую воткнуты в тупой коммутатор 100 Мбит/с: 148800 пакетов/с (а не задумчивый роутер с линуксом). | |
РЕЗУЛЬТАТЫ | |
вызовы CALL это, считай, они по очереди выполняются. | |
test1 - нода сама к себе | |
:timer.tc(fn -> Enum.each(1..1000_000, fn(x)-> :rpc.call(:ui@free, Tm, :test, [x]) end) end) | |
tc - 3778990 | |
264760 rpc_call/sec | |
test2 - нода к ноде на одном хосте | |
:timer.tc(fn -> Enum.each(1..1000_000, fn(x)-> :rpc.call(:ui@free, Tm, :test, [x]) end) end) | |
tc - 75_208_192 | |
13296 rpc_call/sec - оба ядра в 100% | |
test3 - нода к ноде с другого хоста в кластере. | |
:timer.tc(fn -> Enum.each(1..1000_000, fn(x)-> :rpc.call(:ui@free, Tm, :test, [x]) end) end) | |
tc - 360_589_108 | |
2.77 rpc_call/sec - одно ядро сервера в 30%, одно ядро клиента 100%, на коммутаторе активность сети | |
странно. | |
вызовы ASYNC_CALL это, считай, они по очереди выполняются. | |
test4 - нода сама к себе | |
:timer.tc(fn -> Enum.each(1..100_000, fn(x)-> :rpc.async_call(:ui@free, Tm, :test, [x]) |> :rpc.yield() end) end) | |
tc - 4_630_360 | |
21598 rpc_call/sec | |
test5 - нода к ноде на одном хосте - 100к сообщений | |
:timer.tc(fn -> Enum.each(1..100_000, fn(x)-> :rpc.async_call(:ui@free, Tm, :test, [x]) |> :rpc.yield() end) end) | |
tc - 7_887_305 | |
12679 rpc_call/sec - одно ядро 100% второе на 30%. | |
test6 - нода к ноде с другого хоста в кластере. | |
:timer.tc(fn -> Enum.each(1..100_000, fn(x)-> :rpc.async_call(:ui@free, Tm, :test, [x]) |> :rpc.yield() end) end) | |
tc - 41_596_122 | |
2404 rpc_call/sec - одно ядро сервера в 30%, одно ядро клиента 100%, на коммутаторе активность сети | |
процессы через tasks/async в режиме call - еще хуже. | |
а в режиме async: | |
асинк | |
:timer.tc(fn -> | |
1..100_000 |> Enum.map(fn(x) -> | |
Task.async(fn() -> | |
:rpc.async_call(:ui@free, Tm, :test, [x]) |> :rpc.yield() | |
end) | |
end) \ | |
|> Enum.each(fn(task) -> | |
Task.await(task, :infinity) | |
end) \ | |
end) | |
test 7 - нода сама к себе | |
tc - 22_515_768 -> 4441 rpc_call/sec | |
test 8 - нода к ноде на одном хосте | |
tc - 20_767_210 -> 4815 rpc_call/sec | |
test 9 - нода к ноде с другого хоста в кластере. | |
tc - 67_169_712 -> 1488 rpc_call/sec | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Microsoft Windows [Version 6.1.7601]
(c) Корпорация Майкрософт (Microsoft Corp.), 2009. Все права защищены.
C:\Users\sea>iex --sname uui
Interactive Elixir (1.6.5) - press Ctrl+C to exit (type h() ENTER for help)
iex(uui@sea-comp)1> :net_kernel.connect_node(:ui@free)
true
iex(uui@sea-comp)2> :timer.tc(fn -> 1..1_000 |> Enum.map(fn(x)-> :rpc.async_call
(:ui@free, Tm, :test, [x]) end) |> Enum.map(fn(x)-> :rpc.yield(x) end) end)
{31000,
[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
42, 43, 44, 45, 46, 47, 48, 49, ...]}
iex(uui@sea-comp)3> :timer.tc(fn -> 1..10_000 |> Enum.map(fn(x)-> :rpc.async_cal
l(:ui@free, Tm, :test, [x]) end) |> Enum.map(fn(x)-> :rpc.yield(x) end) end)
{265000,
[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
42, 43, 44, 45, 46, 47, 48, 49, ...]}
iex(uui@sea-comp)4> :timer.tc(fn -> 1..100_000 |> Enum.map(fn(x)-> :rpc.async_ca
ll(:ui@free, Tm, :test, [x]) end) |> Enum.map(fn(x)-> :rpc.yield(x) end) end)
{15428000,
[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
42, 43, 44, 45, 46, 47, 48, 49, ...]}
iex(uui@sea-comp)5>
nil
iex(uui@sea-comp)6>
nil
iex(uui@sea-comp)7> :timer.tc(fn -> 1..1_000 |> Enum.map(fn(x)-> :rpc.async_call
(:ui@free, Tm, :test, [x]) end) |> Enum.map(fn(x)-> :rpc.yield(x) end) end)
{47000,
[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
42, 43, 44, 45, 46, 47, 48, 49, ...]}
iex(uui@sea-comp)8> :timer.tc(fn -> 1..1_000 |> Enum.map(fn(x)-> :rpc.async_call
(:ui@free, Tm, :test, [x]) end) |> Enum.map(fn(x)-> :rpc.yield(x) end) end)
{78000,
[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
42, 43, 44, 45, 46, 47, 48, 49, ...]}
iex(uui@sea-comp)9> :timer.tc(fn -> 1..1_000 |> Enum.map(fn(x)-> :rpc.async_call
(:ui@free, Tm, :test, [x]) end) |> Enum.map(fn(x)-> :rpc.yield(x) end) end)
{62000,
[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
42, 43, 44, 45, 46, 47, 48, 49, ...]}
iex(uui@sea-comp)10> :timer.tc(fn -> 1..1_000 |> Enum.map(fn(x)-> :rpc.async_cal
l(:ui@free, Tm, :test, [x]) end) |> Enum.map(fn(x)-> :rpc.yield(x) end) end)
{62000,
[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
42, 43, 44, 45, 46, 47, 48, 49, ...]}
iex(uui@sea-comp)11> :timer.tc(fn -> 1..1_000 |> Enum.map(fn(x)-> :rpc.async_cal
l(:ui@free, Tm, :test, [x]) end) |> Enum.map(fn(x)-> :rpc.yield(x) end) end)
{62000,
[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
42, 43, 44, 45, 46, 47, 48, 49, ...]}
iex(uui@sea-comp)12> :timer.tc(fn -> 1..1_000 |> Enum.map(fn(x)-> :rpc.async_cal
l(:ui@free, Tm, :test, [x]) end) |> Enum.map(fn(x)-> :rpc.yield(x) end) end)
{47000,
[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
42, 43, 44, 45, 46, 47, 48, 49, ...]}
iex(uui@sea-comp)13> :timer.tc(fn -> 1..1_000 |> Enum.map(fn(x)-> :rpc.async_cal
l(:ui@free, Tm, :test, [x]) end) |> Enum.map(fn(x)-> :rpc.yield(x) end) end)
{47000,
[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
42, 43, 44, 45, 46, 47, 48, 49, ...]}
iex(uui@sea-comp)14> :timer.tc(fn -> 1..1_000 |> Enum.map(fn(x)-> :rpc.async_cal
l(:ui@free, Tm, :test, [x]) end) |> Enum.map(fn(x)-> :rpc.yield(x) end) end)
{46000,
[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
42, 43, 44, 45, 46, 47, 48, 49, ...]}
iex(uui@sea-comp)15> :timer.tc(fn -> 1..1_000 |> Enum.map(fn(x)-> :rpc.async_cal
l(:ui@free, Tm, :test, [x]) end) |> Enum.map(fn(x)-> :rpc.yield(x) end) end)
{46000,
[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
42, 43, 44, 45, 46, 47, 48, 49, ...]}
iex(uui@sea-comp)16> :timer.tc(fn -> 1..1_000 |> Enum.map(fn(x)-> :rpc.async_cal
l(:ui@free, Tm, :test, [x]) end) |> Enum.map(fn(x)-> :rpc.yield(x) end) end)
{62000,
[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
42, 43, 44, 45, 46, 47, 48, 49, ...]}
iex(uui@sea-comp)17> :timer.tc(fn -> 1..1_000 |> Enum.map(fn(x)-> :rpc.async_cal
l(:ui@free, Tm, :test, [x]) end) |> Enum.map(fn(x)-> :rpc.yield(x) end) end)
{47000,
[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
42, 43, 44, 45, 46, 47, 48, 49, ...]}
iex(uui@sea-comp)18> :timer.tc(fn -> 1..10_000 |> Enum.map(fn(x)-> :rpc.async_ca
ll(:ui@free, Tm, :test, [x]) end) |> Enum.map(fn(x)-> :rpc.yield(x) end) end)
{280000,
[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
42, 43, 44, 45, 46, 47, 48, 49, ...]}
iex(uui@sea-comp)19> :timer.tc(fn -> 1..10_000 |> Enum.map(fn(x)-> :rpc.async_ca
ll(:ui@free, Tm, :test, [x]) end) |> Enum.map(fn(x)-> :rpc.yield(x) end) end)
{281000,
[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
42, 43, 44, 45, 46, 47, 48, 49, ...]}
iex(uui@sea-comp)20> :timer.tc(fn -> 1..10_000 |> Enum.map(fn(x)-> :rpc.async_ca
ll(:ui@free, Tm, :test, [x]) end) |> Enum.map(fn(x)-> :rpc.yield(x) end) end)
{281000,
[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
42, 43, 44, 45, 46, 47, 48, 49, ...]}
iex(uui@sea-comp)21> :timer.tc(fn -> 1..10_000 |> Enum.map(fn(x)-> :rpc.async_ca
ll(:ui@free, Tm, :test, [x]) end) |> Enum.map(fn(x)-> :rpc.yield(x) end) end)
{280000,
[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
42, 43, 44, 45, 46, 47, 48, 49, ...]}
iex(uui@sea-comp)22> :timer.tc(fn -> 1..100_000 |> Enum.map(fn(x)-> :rpc.async_c
all(:ui@free, Tm, :test, [x]) end) |> Enum.map(fn(x)-> :rpc.yield(x) end) end)
{21372000,
[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
42, 43, 44, 45, 46, 47, 48, 49, ...]}
iex(uui@sea-comp)23> :timer.tc(fn -> 1..100_000 |> Enum.map(fn(x)-> :rpc.async_c
all(:ui@free, Tm, :test, [x]) end) |> Enum.map(fn(x)-> :rpc.yield(x) end) end)
{16957000,
[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
42, 43, 44, 45, 46, 47, 48, 49, ...]}
iex(uui@sea-comp)24>