# Nginx variable to know the number of active connections

**URL:** <https://www.ruby-forum.com/t/nginx-variable-to-know-the-number-of-active-connections/238176>\
**Category:** NGINX\
**Created:** [December 20, 2013, 3:54pm UTC](https://www.ruby-forum.com/t/nginx-variable-to-know-the-number-of-active-connections/238176 "2013-12-20T15:54:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![musicdenotation](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@musicdenotation](https://www.ruby-forum.com/u/musicdenotation)\
**Post date:** [December 20, 2013, 3:54pm UTC](https://www.ruby-forum.com/t/nginx-variable-to-know-the-number-of-active-connections/238176/1 "2013-12-20T15:54:58Z")

</div>

Hello,

Is there a way to get the number of active connections in order to  
activate  
or a not a cache mechanism when nginx is in a high trafic period?

Regards  
Jerome

Posted at Nginx Forum:

> **[nginx variable to know the number of active connections](https://forum.nginx.org/read.php?2,245738,245738#msg-245738)**
>
> Hello, Is there a way to get the number of active connections in order to activate or a not a cache mechanism when nginx is in a high trafic period? Regards Jerome

---

<div class="post-metadata">

**Author:** ![gglamenace](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/ecc23a/32.png) [@gglamenace](https://www.ruby-forum.com/u/gglamenace)\
**Post date:** [December 20, 2013, 4:49pm UTC](https://www.ruby-forum.com/t/nginx-variable-to-know-the-number-of-active-connections/238176/2 "2013-12-20T16:49:18Z")

</div>

Hello!

On Fri, Dec 20, 2013 at 09:54:21AM -0500, gglamenace wrote:

> Hello,
> 
> Is there a way to get the number of active connections in order to activate  
> or a not a cache mechanism when nginx is in a high trafic period?

The following variable are available in the  
ngx\_http\_stub\_status\_module:

$connections\_active,  
$connections\_reading  
$connections\_writing  
$connections\_waiting

–  
Maxim D.  
[http://nginx.org/](http://nginx.org/)

---

<div class="post-metadata">

**Author:** ![gglamenace](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/ecc23a/32.png) [@gglamenace](https://www.ruby-forum.com/u/gglamenace)\
**Post date:** [December 20, 2013, 5:54pm UTC](https://www.ruby-forum.com/t/nginx-variable-to-know-the-number-of-active-connections/238176/3 "2013-12-20T17:54:44Z")

</div>

Oh great, so i can parameter using a cache mechanism using  
fastcgi\_cache\_path or the Lua Module SRCACHE for my PHP upstream block  
simply by checking for example $connections\_waiting on each request.  
I don’t know exactly what would be a right setting for using a cache by  
testing $connections\_waiting. I have to do some tests.

thank you

Jérôme

Posted at Nginx Forum:

> **[Re: nginx variable to know the number of active connections](https://forum.nginx.org/read.php?2,245738,245741#msg-245741)**
>
> Hello, Is there a way to get the number of active connections in order to activate or a not a cache mechanism when nginx is in a high trafic period? Regards Jerome
