Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mtproto_proxy
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
mtproto_proxy
Commits
9e0eaa06
Unverified
Commit
9e0eaa06
authored
Oct 27, 2018
by
Сергей Прохоров
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make it possible to tune socket buffer sizes
parent
d49a451d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
10 deletions
+18
-10
mtp_handler.erl
src/mtp_handler.erl
+13
-10
mtproto_proxy.app.src
src/mtproto_proxy.app.src
+5
-0
No files found.
src/mtp_handler.erl
View file @
9e0eaa06
...
@@ -63,12 +63,15 @@ ranch_init({Ref, Socket, Transport, _} = Opts) ->
...
@@ -63,12 +63,15 @@ ranch_init({Ref, Socket, Transport, _} = Opts) ->
case
init
(
Opts
)
of
case
init
(
Opts
)
of
{
ok
,
State
}
->
{
ok
,
State
}
->
ok
=
ranch
:
accept_ack
(
Ref
),
ok
=
ranch
:
accept_ack
(
Ref
),
ok
=
Transport
:
setopts
(
Socket
,
BufSize
=
application
:
get_env
(
?
APP
,
upstream_socket_buffer_size
,
[{
active
,
once
},
?
MAX_SOCK_BUF_SIZE
),
%% {recbuf, ?MAX_SOCK_BUF_SIZE},
ok
=
Transport
:
setopts
(
%% {sndbuf, ?MAX_SOCK_BUF_SIZE},
Socket
,
{
buffer
,
?
MAX_SOCK_BUF_SIZE
}
[{
active
,
once
},
]),
%% {recbuf, ?MAX_SOCK_BUF_SIZE},
%% {sndbuf, ?MAX_SOCK_BUF_SIZE},
{
buffer
,
BufSize
}
]),
gen_server
:
enter_loop
(
?
MODULE
,
[],
State
);
gen_server
:
enter_loop
(
?
MODULE
,
[],
State
);
error
->
error
->
mtp_metric
:
count_inc
([
?
APP
,
in_connection_closed
,
total
],
1
,
#
{}),
mtp_metric
:
count_inc
([
?
APP
,
in_connection_closed
,
total
],
1
,
#
{}),
...
@@ -361,10 +364,13 @@ handle_upstream_header(DcId, S) ->
...
@@ -361,10 +364,13 @@ handle_upstream_header(DcId, S) ->
-
define
(
SEND_TIMEOUT
,
60
*
1000
).
-
define
(
SEND_TIMEOUT
,
60
*
1000
).
connect
(
Host
,
Port
)
->
connect
(
Host
,
Port
)
->
BufSize
=
application
:
get_env
(
?
APP
,
downstream_socket_buffer_size
,
?
MAX_SOCK_BUF_SIZE
),
SockOpts
=
[{
active
,
once
},
SockOpts
=
[{
active
,
once
},
{
packet
,
raw
},
{
packet
,
raw
},
binary
,
{
mode
,
binary
}
,
{
send_timeout
,
?
SEND_TIMEOUT
},
{
send_timeout
,
?
SEND_TIMEOUT
},
{
buffer
,
BufSize
},
%% {nodelay, true},
%% {nodelay, true},
{
keepalive
,
true
}],
{
keepalive
,
true
}],
case
mtp_metric
:
rt
([
?
APP
,
downstream_connect_duration
,
seconds
],
case
mtp_metric
:
rt
([
?
APP
,
downstream_connect_duration
,
seconds
],
...
@@ -372,9 +378,6 @@ connect(Host, Port) ->
...
@@ -372,9 +378,6 @@ connect(Host, Port) ->
gen_tcp
:
connect
(
Host
,
Port
,
SockOpts
,
?
CONN_TIMEOUT
)
gen_tcp
:
connect
(
Host
,
Port
,
SockOpts
,
?
CONN_TIMEOUT
)
end
)
of
end
)
of
{
ok
,
Sock
}
->
{
ok
,
Sock
}
->
ok
=
inet
:
setopts
(
Sock
,
[
%% {recbuf, ?MAX_SOCK_BUF_SIZE},
%% {sndbuf, ?MAX_SOCK_BUF_SIZE},
{
buffer
,
?
MAX_SOCK_BUF_SIZE
}]),
{
ok
,
Sock
};
{
ok
,
Sock
};
{
error
,
_}
=
Err
->
{
error
,
_}
=
Err
->
Err
Err
...
...
src/mtproto_proxy.app.src
View file @
9e0eaa06
...
@@ -60,6 +60,11 @@
...
@@ -60,6 +60,11 @@
%% module with function `notify/4' exported.
%% module with function `notify/4' exported.
%% See mtp_metric:notify/4 for details
%% See mtp_metric:notify/4 for details
%% {metric_backend, my_metric_backend}
%% {metric_backend, my_metric_backend}
%% User-space recv socket buffer sizes. Set to higher if you have
%% enough RAM
%% {upstream_socket_buffer_size, 51200}, %50kb
%% {downstream_socket_buffer_size, 51200} %50kb
]},
]},
{modules, []},
{modules, []},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment