TCP stack throughput
Ulf Wiger (AL/EAB)
ulf.wiger@REDACTED
Tue Jul 5 14:34:43 CEST 2005
I rewrote the tcp_server module slightly (attached),
and ran the server and client in different shells to
better observe what's happening.
I tried setting the acceptor process to high priority until
the accept() call returned, then setting it to normal prio,
yielding, and then calling the handler. That didn't help.
The delay is not due to scheduling delay caused by processing
backlog in erlang.
I then wrapped the inet:accept() call with a timer:tc()
and logged the result in an ets table. After trying 1000
clients, I checked the ets table, and found that the longest
accept() call took 43 seconds. That's running one acceptor
at a time. See below.
I also noticed that the accept calls seem to go quickly in
batches of 100-200, then followed by an increasingly long
delay.
A possibility is perhaps that there are retransmissions
at the TCP level. But previous runs with tcpdump gave no
such indications.
/Uffe
start_acceptor(S, Fun, T) ->
Parent = self(),
spawn_opt(
fun() ->
case timer:tc(inet_tcp, accept, [S]) of
{Time, {ok, Sock}} ->
ets:insert(stats, {self(), Time}),
Parent ! accepted,
process_flag(priority, normal),
erlang:yield(),
receive
{tcp, Sock, Msg} ->
Prev = ets:update_counter(T, total, 1),
io:format("<~p> ", [Prev]),
Fun(Msg, Sock),
inet_tcp:close(Sock);
Msg ->
io:format("Msg = ~p~n", [Msg])
end;
Error ->
erlang:fault(Error)
end
end, [link, {priority, high}]),
receive
accepted ->
start_acceptor(S, Fun, T)
end.
4> io:format("~p~n", [v(2)]).
[{<0.40.0>,43316529},
{<0.723.0>,26158659},
{<0.627.0>,12659283},
{<0.506.0>,5538478},
{<0.396.0>,1964537},
{<0.567.0>,419001},
{<0.667.0>,418777},
{<0.436.0>,397587},
{<0.511.0>,369515},
{<0.404.0>,368789},
{<0.691.0>,188574},
{<0.595.0>,186015},
{<0.468.0>,178119},
{<0.683.0>,127997},
{<0.452.0>,119223},
{<0.583.0>,118169},
{<0.150.0>,117279},
{<0.140.0>,103751},
{<0.356.0>,76253},
{<0.252.0>,58598},
{<0.364.0>,52827},
{<0.428.0>,50812},
{<0.302.0>,45687},
{<0.199.0>,39077},
{<0.77.0>,35216},
{<0.244.0>,34073},
{<0.148.0>,31787},
{<0.388.0>,26835},
{<0.643.0>,20185},
{<0.41.0>,19363},
{<0.420.0>,18621},
{<0.294.0>,18435},
{<0.88.0>,17394},
{<0.635.0>,17230},
{<0.49.0>,14304},
{<0.587.0>,12749},
{<0.50.0>,11834},
{<0.651.0>,10356},
{<0.551.0>,9884},
{<0.699.0>,9562},
{<0.474.0>,9471},
{<0.87.0>,9411},
{<0.707.0>,9321},
{<0.675.0>,9027},
{<0.743.0>,9001},
{<0.751.0>,8918},
{<0.365.0>,8869},
{<0.535.0>,8674},
{<0.490.0>,8666},
{<0.767.0>,8644},
{<0.93.0>,8605},
{<0.611.0>,8598},
{<0.775.0>,8582},
{<0.498.0>,8577},
{<0.619.0>,8553},
{<0.543.0>,8533},
{<0.527.0>,8479},
{<0.482.0>,8372},
{<0.519.0>,8369},
{<0.366.0>,8359},
{<0.412.0>,8350},
{<0.57.0>,8309},
{<0.92.0>,8292},
{<0.575.0>,8191},
{<0.309.0>,8184},
{<0.759.0>,8147},
{<0.603.0>,8135},
{<0.368.0>,8120},
{<0.85.0>,8089},
{<0.460.0>,8014},
{<0.151.0>,8003},
{<0.735.0>,8001},
{<0.52.0>,7991},
{<0.56.0>,7980},
{<0.86.0>,7974},
{<0.303.0>,7971},
{<0.94.0>,7960},
{<0.367.0>,7922},
{<0.51.0>,7920},
{<0.444.0>,7904},
{<0.78.0>,7900},
{<0.369.0>,7876},
{<0.152.0>,7872},
{<0.58.0>,7870},
{<0.89.0>,7869},
{<0.311.0>,7862},
{<0.83.0>,7854},
{<0.153.0>,7844},
{<0.304.0>,7842},
{<0.156.0>,7832},
{<0.310.0>,7831},
{<0.155.0>,7830},
{<0.305.0>,7829},
{<0.308.0>,7821},
{<0.81.0>,7818},
{<0.90.0>,7817},
{<0.149.0>,7810},
{<0.91.0>,7804},
{<0.55.0>,7799},
{<0.53.0>,7798},
{<0.80.0>,7790},
{<0.306.0>,7783},
{<0.82.0>,7770},
{<0.312.0>,7760},
{<0.157.0>,7750},
{<0.154.0>,7748},
{<0.307.0>,7744},
{<0.159.0>,7742},
{<0.95.0>,7740},
{<0.59.0>,7733},
{<0.158.0>,7724},
{<0.161.0>,7715},
{<0.79.0>,7700},
{<0.160.0>,7678},
{<0.54.0>,7677},
{<0.84.0>,7676},
{<0.559.0>,7370},
{<0.715.0>,6912},
{<0.659.0>,5917},
{<0.370.0>,5507},
{<0.162.0>,4666},
{<0.313.0>,2693},
{<0.176.0>,2637},
{<0.69.0>,2596},
{<0.124.0>,2576},
{<0.321.0>,2560},
{<0.200.0>,2302},
{<0.270.0>,2296},
{<0.96.0>,2240},
{<0.380.0>,2234},
{<0.392.0>,2198},
{<0.60.0>,2190},
{<0.211.0>,2128},
{<0.100.0>,2048},
{<0.333.0>,2019},
{<0.282.0>,1993},
{<0.112.0>,1988},
{<0.223.0>,1983},
{<0.345.0>,1959},
{<0.163.0>,1944},
{<0.235.0>,1939},
{<0.371.0>,1930},
{<0.136.0>,1923},
{<0.201.0>,1809},
{<0.389.0>,1777},
{<0.314.0>,1767},
{<0.187.0>,1748},
{<0.61.0>,1734},
{<0.97.0>,1731},
{<0.167.0>,1616},
{<0.209.0>,1486},
{<0.258.0>,1277},
{<0.253.0>,1270},
{<0.114.0>,1152},
{<0.179.0>,1149},
{<0.390.0>,1140},
{<0.113.0>,1088},
{<0.170.0>,1050},
{<0.236.0>,1035},
{<0.378.0>,1034},
{<0.281.0>,1030},
{<0.70.0>,1029},
{<0.164.0>,1023},
{<0.72.0>,1017},
{<0.177.0>,1016},
{<0.217.0>,1014},
{<0.125.0>,1009},
{<0.212.0>,1007},
{<0.322.0>,1006},
{<0.101.0>,999},
{<0.188.0>,999},
{<0.268.0>,998},
{<0.73.0>,997},
{<0.271.0>,997},
{<0.62.0>,992},
{<0.254.0>,991},
{<0.393.0>,989},
{<0.372.0>,986},
{<0.168.0>,985},
{<0.381.0>,983},
{<0.331.0>,982},
{<0.210.0>,981},
{<0.315.0>,980},
{<0.74.0>,979},
{<0.283.0>,976},
{<0.224.0>,975},
{<0.137.0>,974},
{<0.98.0>,974},
{<0.132.0>,971},
{<0.261.0>,970},
{<0.259.0>,970},
{<0.273.0>,963},
{<0.391.0>,961},
{<0.99.0>,960},
{<0.63.0>,959},
{<0.202.0>,959},
{<0.76.0>,958},
{<0.334.0>,958},
{<0.65.0>,956},
{<0.166.0>,956},
{<0.71.0>,954},
{<0.67.0>,952},
{<0.165.0>,951},
{<0.255.0>,951},
{<0.64.0>,950},
{<0.104.0>,949},
{<0.110.0>,949},
{<0.115.0>,949},
{<0.257.0>,948},
{<0.178.0>,948},
{<0.341.0>,947},
{<0.66.0>,947},
{<0.387.0>,947},
{<0.75.0>,946},
{<0.227.0>,945},
{<0.174.0>,945},
{<0.256.0>,945},
{<0.204.0>,945},
{<0.171.0>,944},
{<0.316.0>,943},
{<0.68.0>,941},
{<0.172.0>,940},
{<0.346.0>,939},
{<0.260.0>,938},
{<0.373.0>,937},
{<0.105.0>,937},
{<0.323.0>,936},
{<0.218.0>,936},
{<0.280.0>,936},
{<0.317.0>,936},
{<0.169.0>,935},
{<0.126.0>,935},
{<0.133.0>,935},
{<0.102.0>,934},
{<0.103.0>,934},
{<0.213.0>,934},
{<0.111.0>,934},
{<0.214.0>,934},
{<0.266.0>,933},
{<0.109.0>,933},
{<0.375.0>,933},
{<0.265.0>,933},
{<0.377.0>,932},
{<0.262.0>,932},
{<0.263.0>,932},
{<0.206.0>,932},
{<0.264.0>,932},
{<0.379.0>,932},
{<0.269.0>,931},
{<0.237.0>,931},
{<0.173.0>,930},
{<0.290.0>,930},
{<0.203.0>,930},
{<0.189.0>,929},
{<0.180.0>,929},
{<0.208.0>,929},
{<0.216.0>,927},
{<0.318.0>,926},
{<0.123.0>,925},
{<0.107.0>,925},
{<0.319.0>,925},
{<0.175.0>,924},
{<0.267.0>,924},
{<0.374.0>,923},
{<0.119.0>,923},
{<0.274.0>,923},
{<0.116.0>,923},
{<0.207.0>,922},
{<0.350.0>,922},
{<0.293.0>,922},
{<0.376.0>,922},
{<0.106.0>,921},
{<0.205.0>,921},
{<0.320.0>,921},
{<0.198.0>,921},
{<0.272.0>,920},
{<0.186.0>,920},
{<0.182.0>,920},
{<0.120.0>,919},
{<0.215.0>,919},
{<0.222.0>,919},
{<0.121.0>,919},
{<0.194.0>,919},
{<0.117.0>,919},
{<0.135.0>,919},
{<0.108.0>,919},
{<0.190.0>,918},
{<0.230.0>,918},
{<0.228.0>,918},
{<0.291.0>,917},
{<0.278.0>,917},
{<0.192.0>,917},
{<0.284.0>,917},
{<0.127.0>,916},
{<0.240.0>,916},
{<0.122.0>,916},
{<0.184.0>,916},
{<0.279.0>,916},
{<0.226.0>,916},
{<0.332.0>,915},
{<0.385.0>,915},
{<0.220.0>,915},
{<0.138.0>,914},
{<0.219.0>,914},
{<0.234.0>,914},
{<0.275.0>,913},
{<0.118.0>,913},
{<0.292.0>,912},
{<0.325.0>,912},
{<0.394.0>,912},
{<0.383.0>,912},
{<0.196.0>,912},
{<0.134.0>,911},
{<0.328.0>,911},
{<0.181.0>,911},
{<0.129.0>,911},
{<0.276.0>,911},
{<0.395.0>,911},
{<0.139.0>,911},
{<0.335.0>,910},
{<0.131.0>,910},
{<0.351.0>,910},
{<0.225.0>,909},
{<0.238.0>,908},
{<0.324.0>,908},
{<0.329.0>,908},
{<0.183.0>,908},
{<0.221.0>,907},
{<0.197.0>,907},
{<0.193.0>,907},
{<0.242.0>,907},
{<0.277.0>,906},
{<0.195.0>,906},
{<0.327.0>,905},
{<0.326.0>,904},
{<0.353.0>,904},
{<0.342.0>,904},
{<0.337.0>,903},
{<0.232.0>,903},
{<0.191.0>,902},
{<0.343.0>,902},
{<0.229.0>,902},
{<0.288.0>,902},
{<0.239.0>,902},
{<0.285.0>,902},
{<0.289.0>,902},
{<0.347.0>,902},
{<0.128.0>,901},
{<0.352.0>,901},
{<0.338.0>,901},
{<0.386.0>,901},
{<0.384.0>,900},
{<0.243.0>,900},
{<0.382.0>,900},
{<0.185.0>,900},
{<0.339.0>,899},
{<0.336.0>,899},
{<0.286.0>,899},
{<0.340.0>,899},
{<0.348.0>,899},
{<0.354.0>,899},
{<0.349.0>,898},
{<0.231.0>,898},
{<0.355.0>,898},
{<0.233.0>,897},
{<0.330.0>,897},
{<0.241.0>,895},
{<0.287.0>,892},
{<0.130.0>,892},
{<0.344.0>,891},
{<0.45.0>,261},
{<0.628.0>,224},
{<0.728.0>,223},
{<0.507.0>,223},
{<0.453.0>,223},
{<0.397.0>,222},
{<0.596.0>,222},
{<0.636.0>,221},
{<0.437.0>,221},
{<0.588.0>,221},
{<0.692.0>,220},
{<0.584.0>,220},
{<0.141.0>,220},
{<0.684.0>,219},
{<0.512.0>,219},
{<0.469.0>,218},
{<0.568.0>,218},
{<0.245.0>,218},
{<0.644.0>,217},
{<0.668.0>,217},
{<0.429.0>,215},
{<0.357.0>,214},
{<0.405.0>,214},
{<0.716.0>,210},
{<0.421.0>,209},
{<0.660.0>,207},
{<0.475.0>,205},
{<0.42.0>,203},
{<0.413.0>,202},
{<0.652.0>,202},
{<0.604.0>,202},
{<0.520.0>,201},
{<0.445.0>,201},
{<0.536.0>,200},
{<0.461.0>,199},
{<0.676.0>,199},
{<0.576.0>,198},
{<0.295.0>,198},
{<0.552.0>,198},
{<0.483.0>,197},
{<0.700.0>,197},
{<0.752.0>,196},
{<0.462.0>,196},
{<0.499.0>,195},
{<0.528.0>,195},
{<0.491.0>,195},
{<0.620.0>,195},
{<0.560.0>,194},
{<0.612.0>,194},
{<0.544.0>,193},
{<0.744.0>,192},
{<0.736.0>,192},
{<0.46.0>,192},
{<0.760.0>,192},
{<0.708.0>,191},
{<0.776.0>,191},
{<0.358.0>,191},
{<0.597.0>,191},
{<0.508.0>,191},
{<0.142.0>,190},
{<0.768.0>,190},
{<0.631.0>,189},
{<0.556.0>,189},
{<0.569.0>,188},
{<0.246.0>,188},
{<0.693.0>,187},
{<0.513.0>,187},
{<0.669.0>,187},
{<0.438.0>,187},
{<0.296.0>,187},
{<0.629.0>,187},
{<0.589.0>,187},
{<0.717.0>,187},
{<0.43.0>,186},
{<0.585.0>,186},
{<0.470.0>,185},
{<0.685.0>,185},
{<0.406.0>,184},
{<0.637.0>,183},
{<0.430.0>,183},
{<0.454.0>,183},
{<0.476.0>,183},
{<0.645.0>,182},
{<0.398.0>,182},
{<0.422.0>,181},
{<0.661.0>,181},
{<0.605.0>,180},
{<0.729.0>,180},
{<0.146.0>,180},
{<0.359.0>,179},
{<0.143.0>,179},
{<0.247.0>,179},
{<0.545.0>,179},
{<0.529.0>,179},
{<0.521.0>,179},
{<0.577.0>,179},
{<0.509.0>,179},
{<0.630.0>,178},
{<0.250.0>,178},
{<0.360.0>,178},
{<0.248.0>,178},
{<0.48.0>,178},
{<0.446.0>,178},
{<0.570.0>,178},
{<0.553.0>,178},
{<0.730.0>,178},
{<0.537.0>,178},
{<0.47.0>,178},
{<0.361.0>,178},
{<0.144.0>,178},
{<0.363.0>,178},
{<0.670.0>,177},
{<0.414.0>,177},
{<0.492.0>,177},
{<0.471.0>,177},
{<0.561.0>,177},
{<0.455.0>,177},
{<0.653.0>,177},
{<0.251.0>,177},
{<0.613.0>,177},
{<0.145.0>,177},
{<0.147.0>,177},
{<0.297.0>,177},
{<0.249.0>,177},
{<0.709.0>,176},
{<0.44.0>,176},
{<0.777.0>,176},
{<0.591.0>,176},
{<0.638.0>,176},
{<0.472.0>,176},
{<0.594.0>,176},
{<0.586.0>,176},
{<0.362.0>,176},
{<0.298.0>,176},
{<0.514.0>,176},
{<0.441.0>,176},
{<0.761.0>,176},
{<0.745.0>,176},
{<0.593.0>,176},
{<0.677.0>,176},
{<0.694.0>,176},
{<0.599.0>,176},
{<0.632.0>,176},
{<0.592.0>,176},
{<0.301.0>,175},
{<0.517.0>,175},
{<0.687.0>,175},
{<0.686.0>,175},
{<0.300.0>,175},
{<0.431.0>,175},
{<0.598.0>,175},
{<0.600.0>,175},
{<0.484.0>,175},
{<0.571.0>,175},
{<0.478.0>,175},
{<0.500.0>,175},
{<0.439.0>,175},
{<0.457.0>,175},
{<0.456.0>,175},
{<0.672.0>,174},
{<0.732.0>,174},
{<0.510.0>,174},
{<0.572.0>,174},
{<0.695.0>,174},
{<0.769.0>,174},
{<0.701.0>,174},
{<0.477.0>,174},
{<0.590.0>,174},
{<0.621.0>,174},
{<0.671.0>,174},
{<0.554.0>,174},
{<0.688.0>,174},
{<0.515.0>,174},
{<0.440.0>,174},
{<0.473.0>,174},
{<0.458.0>,174},
{<0.690.0>,174},
{<0.647.0>,174},
{<0.633.0>,174},
{<0.299.0>,174},
{<0.442.0>,174},
{<0.402.0>,173},
{<0.698.0>,173},
{<0.663.0>,173},
{<0.696.0>,173},
{<0.689.0>,173},
{<0.399.0>,173},
{<0.737.0>,173},
{<0.718.0>,173},
{<0.601.0>,173},
{<0.459.0>,173},
{<0.639.0>,173},
{<0.719.0>,173},
{<0.426.0>,173},
{<0.516.0>,173},
{<0.662.0>,173},
{<0.602.0>,173},
{<0.731.0>,173},
{<0.753.0>,173},
{<0.409.0>,172},
{<0.424.0>,172},
{<0.407.0>,172},
{<0.733.0>,172},
{<0.634.0>,172},
{<0.640.0>,172},
{<0.558.0>,172},
{<0.518.0>,172},
{<0.608.0>,172},
{<0.463.0>,172},
{<0.573.0>,172},
{<0.646.0>,172},
{<0.674.0>,172},
{<0.654.0>,172},
{<0.734.0>,172},
{<0.427.0>,172},
{<0.673.0>,172},
{<0.423.0>,171},
{<0.425.0>,171},
{<0.524.0>,171},
{<0.650.0>,171},
{<0.443.0>,171},
{<0.546.0>,171},
{<0.666.0>,171},
{<0.607.0>,171},
{<0.408.0>,171},
{<0.481.0>,171},
{<0.433.0>,171},
{<0.664.0>,171},
{<0.574.0>,171},
{<0.641.0>,171},
{<0.720.0>,171},
{<0.432.0>,171},
{<0.757.0>,171},
{<0.410.0>,171},
{<0.522.0>,171},
{<0.578.0>,171},
{<0.434.0>,171},
{<0.401.0>,171},
{<0.400.0>,171},
{<0.467.0>,170},
{<0.501.0>,170},
{<0.606.0>,170},
{<0.403.0>,170},
{<0.755.0>,170},
{<0.655.0>,170},
{<0.754.0>,170},
{<0.411.0>,170},
{<0.480.0>,170},
{<0.697.0>,170},
{<0.615.0>,170},
{<0.495.0>,170},
{<0.582.0>,170},
{<0.642.0>,170},
{<0.448.0>,170},
{<0.756.0>,170},
{<0.648.0>,170},
{<0.464.0>,170},
{<0.562.0>,170},
{<0.526.0>,170},
{<0.532.0>,170},
{<0.623.0>,170},
{<0.494.0>,170},
{<0.649.0>,170},
{<0.487.0>,170},
{<0.721.0>,170},
{<0.555.0>,170},
{<0.614.0>,170},
{<0.557.0>,169},
{<0.502.0>,169},
{<0.746.0>,169},
{<0.711.0>,169},
{<0.493.0>,169},
{<0.665.0>,169},
{<0.505.0>,169},
{<0.435.0>,169},
{<0.710.0>,169},
{<0.722.0>,169},
{<0.763.0>,169},
{<0.579.0>,169},
{<0.762.0>,169},
{<0.530.0>,169},
{<0.523.0>,169},
{<0.486.0>,169},
{<0.488.0>,169},
{<0.616.0>,169},
{<0.771.0>,168},
{<0.542.0>,168},
{<0.622.0>,168},
{<0.765.0>,168},
{<0.739.0>,168},
{<0.779.0>,168},
{<0.703.0>,168},
{<0.465.0>,168},
{<0.563.0>,168},
{<0.658.0>,168},
{<0.702.0>,168},
{<0.450.0>,168},
{<0.773.0>,168},
{<0.738.0>,168},
{<0.479.0>,168},
{<0.451.0>,168},
{<0.503.0>,168},
{<0.497.0>,168},
{<0.525.0>,168},
{<0.466.0>,168},
{<0.531.0>,168},
{<0.547.0>,168},
{<0.580.0>,168},
{<0.447.0>,168},
{<0.656.0>,168},
{<0.539.0>,167},
{<0.533.0>,167},
{<0.713.0>,167},
{<0.449.0>,167},
{<0.766.0>,167},
{<0.624.0>,167},
{<0.609.0>,167},
{<0.485.0>,167},
{<0.740.0>,167},
{<0.496.0>,167},
{<0.772.0>,167},
{<0.489.0>,167},
{<0.538.0>,167},
{<0.617.0>,167},
{<0.778.0>,167},
{<0.548.0>,167},
{<0.541.0>,167},
{<0.748.0>,167},
{<0.678.0>,167},
{<0.770.0>,167},
{<0.750.0>,167},
{<0.504.0>,167},
{<0.742.0>,167},
{<0.774.0>,167},
{<0.540.0>,167},
{<0.626.0>,167},
{<0.680.0>,166},
{<0.704.0>,166},
{<0.741.0>,166},
{<0.625.0>,166},
{<0.565.0>,166},
{<0.764.0>,166},
{<0.419.0>,166},
{<0.705.0>,166},
{<0.780.0>,166},
{<0.712.0>,166},
{<0.747.0>,166},
{<0.681.0>,166},
{<0.418.0>,166},
{<0.758.0>,166},
{<0.679.0>,166},
{<0.534.0>,166},
{<0.682.0>,166},
{<0.782.0>,166},
{<0.564.0>,165},
{<0.415.0>,165},
{<0.581.0>,165},
{<0.550.0>,165},
{<0.714.0>,165},
{<0.610.0>,165},
{<0.549.0>,165},
{<0.566.0>,165},
{<0.618.0>,165},
{<0.706.0>,165},
{<0.416.0>,165},
{<0.781.0>,165},
{<0.417.0>,165},
{<0.657.0>,165},
{<0.749.0>,164}]
ok
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fac.tar.gz
Type: application/x-gzip
Size: 1660 bytes
Desc: fac.tar.gz
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20050705/37826a02/attachment.bin>
More information about the erlang-questions
mailing list