* [tarantool-patches] [PATCH] iproto: report active connections number
@ 2019-02-24 23:52 Ilya Kosarev
2019-02-25 11:34 ` Vladimir Davydov
0 siblings, 1 reply; 2+ messages in thread
From: Ilya Kosarev @ 2019-02-24 23:52 UTC (permalink / raw)
To: tarantool-patches; +Cc: georgy, i.kosarev, Ilya Kosarev
Now there is new member in box.stat.net() called "CONNECTIONS" which is a number of active iproto connections.
Closes #3905
---
Branch: https://github.com/tarantool/tarantool/tree/i.kosarev/gh-3905-report-connections-number
Issue: https://github.com/tarantool/tarantool/issues/3905
src/box/iproto.cc | 7 ++++++-
test/box/stat_net.result | 8 ++++++++
test/box/stat_net.test.lua | 2 ++
3 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/src/box/iproto.cc b/src/box/iproto.cc
index a08c8c5cb..a20a7b005 100644
--- a/src/box/iproto.cc
+++ b/src/box/iproto.cc
@@ -267,10 +267,11 @@ struct rmean *rmean_net;
enum rmean_net_name {
IPROTO_SENT,
IPROTO_RECEIVED,
+ IPROTO_CONNECTIONS,
IPROTO_LAST,
};
-const char *rmean_net_strings[IPROTO_LAST] = { "SENT", "RECEIVED" };
+const char *rmean_net_strings[IPROTO_LAST] = { "SENT", "RECEIVED", "CONNECTIONS" };
static void
tx_process_destroy(struct cmsg *m);
@@ -579,6 +580,8 @@ iproto_connection_close(struct iproto_connection *con)
/* Make evio_has_fd() happy */
con->input.fd = con->output.fd = -1;
close(fd);
+ /* Count statistics */
+ rmean_collect(rmean_net, IPROTO_CONNECTIONS, -1);
/*
* Discard unparsed data, to recycle the
* connection in net_send_msg() as soon as all
@@ -1853,6 +1856,8 @@ iproto_on_accept(struct evio_service * /* service */, int fd,
struct iproto_connection *con = iproto_connection_new(fd);
if (con == NULL)
return -1;
+ /* Count statistics */
+ rmean_collect(rmean_net, IPROTO_CONNECTIONS, 1);
/*
* Ignore msg allocation failure - the queue size is
* fixed so there is a limited number of msgs in
diff --git a/test/box/stat_net.result b/test/box/stat_net.result
index b3e3db11f..be7f2ff8a 100644
--- a/test/box/stat_net.result
+++ b/test/box/stat_net.result
@@ -46,6 +46,10 @@ box.stat.net.RECEIVED.total > 0
---
- true
...
+box.stat.net.CONNECTIONS.total > 0
+---
+- true
+...
-- box.stat.net.EVENTS.total > 0
-- box.stat.net.LOCKS.total > 0
-- reset
@@ -60,6 +64,10 @@ box.stat.net.RECEIVED.total
---
- 0
...
+box.stat.net.CONNECTIONS.total
+---
+- 0
+...
space:drop() -- tweedledum
---
...
diff --git a/test/box/stat_net.test.lua b/test/box/stat_net.test.lua
index 808bb71e7..43d388ccd 100644
--- a/test/box/stat_net.test.lua
+++ b/test/box/stat_net.test.lua
@@ -18,6 +18,7 @@ cn.space.tweedledum:select() --small request
box.stat.net.SENT.total > 0
box.stat.net.RECEIVED.total > 0
+box.stat.net.CONNECTIONS.total > 0
-- box.stat.net.EVENTS.total > 0
-- box.stat.net.LOCKS.total > 0
@@ -25,6 +26,7 @@ box.stat.net.RECEIVED.total > 0
box.stat.reset()
box.stat.net.SENT.total
box.stat.net.RECEIVED.total
+box.stat.net.CONNECTIONS.total
space:drop() -- tweedledum
cn:close()
--
2.17.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [tarantool-patches] [PATCH] iproto: report active connections number
2019-02-24 23:52 [tarantool-patches] [PATCH] iproto: report active connections number Ilya Kosarev
@ 2019-02-25 11:34 ` Vladimir Davydov
0 siblings, 0 replies; 2+ messages in thread
From: Vladimir Davydov @ 2019-02-25 11:34 UTC (permalink / raw)
To: Ilya Kosarev; +Cc: tarantool-patches, georgy, i.kosarev
On Mon, Feb 25, 2019 at 02:52:25AM +0300, Ilya Kosarev wrote:
> Now there is new member in box.stat.net() called "CONNECTIONS" which is a number of active iproto connections.
>
> Closes #3905
> ---
> Branch: https://github.com/tarantool/tarantool/tree/i.kosarev/gh-3905-report-connections-number
> Issue: https://github.com/tarantool/tarantool/issues/3905
My comments to "[PATCH] Close socket explicitly before wal_dir at exit"
regarding the commit meesage are valid for this patch as well. Please
fix accordingly.
>
> src/box/iproto.cc | 7 ++++++-
> test/box/stat_net.result | 8 ++++++++
> test/box/stat_net.test.lua | 2 ++
> 3 files changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/src/box/iproto.cc b/src/box/iproto.cc
> index a08c8c5cb..a20a7b005 100644
> --- a/src/box/iproto.cc
> +++ b/src/box/iproto.cc
> @@ -267,10 +267,11 @@ struct rmean *rmean_net;
> enum rmean_net_name {
> IPROTO_SENT,
> IPROTO_RECEIVED,
> + IPROTO_CONNECTIONS,
> IPROTO_LAST,
> };
>
> -const char *rmean_net_strings[IPROTO_LAST] = { "SENT", "RECEIVED" };
> +const char *rmean_net_strings[IPROTO_LAST] = { "SENT", "RECEIVED", "CONNECTIONS" };
No-no-no. RPS doesn't make any sense at all for the number of active
connections. Please don't extend it. Add a simple counter instead.
Perhaps, you don't even need to do that and it's possible to extract
the number of connections from iproto_connection_pool stats. Check it
out, please.
>
> static void
> tx_process_destroy(struct cmsg *m);
> @@ -579,6 +580,8 @@ iproto_connection_close(struct iproto_connection *con)
> /* Make evio_has_fd() happy */
> con->input.fd = con->output.fd = -1;
> close(fd);
> + /* Count statistics */
> + rmean_collect(rmean_net, IPROTO_CONNECTIONS, -1);
> /*
> * Discard unparsed data, to recycle the
> * connection in net_send_msg() as soon as all
> @@ -1853,6 +1856,8 @@ iproto_on_accept(struct evio_service * /* service */, int fd,
> struct iproto_connection *con = iproto_connection_new(fd);
> if (con == NULL)
> return -1;
> + /* Count statistics */
> + rmean_collect(rmean_net, IPROTO_CONNECTIONS, 1);
> /*
> * Ignore msg allocation failure - the queue size is
> * fixed so there is a limited number of msgs in
> diff --git a/test/box/stat_net.result b/test/box/stat_net.result
> index b3e3db11f..be7f2ff8a 100644
> --- a/test/box/stat_net.result
> +++ b/test/box/stat_net.result
> @@ -46,6 +46,10 @@ box.stat.net.RECEIVED.total > 0
> ---
> - true
> ...
> +box.stat.net.CONNECTIONS.total > 0
> +---
> +- true
> +...
The test is poor. I want to see that you actually check that the number
of connections is accounted correctly. Please use net.box module to
establish several connections and check that the number reported in the
stats is correct.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-02-25 11:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-24 23:52 [tarantool-patches] [PATCH] iproto: report active connections number Ilya Kosarev
2019-02-25 11:34 ` Vladimir Davydov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox