# What's the best way to have some kind of state in a custom module?

**URL:** <https://www.ruby-forum.com/t/whats-the-best-way-to-have-some-kind-of-state-in-a-custom-module/227084>\
**Category:** NGINX\
**Created:** [March 3, 2013, 10:44pm UTC](https://www.ruby-forum.com/t/whats-the-best-way-to-have-some-kind-of-state-in-a-custom-module/227084 "2013-03-03T22:44:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sergey\_Zhemzhitsky](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b2d939/32.png) [@Sergey\_Zhemzhitsky](https://www.ruby-forum.com/u/Sergey_Zhemzhitsky)\
**Post date:** [March 3, 2013, 10:44pm UTC](https://www.ruby-forum.com/t/whats-the-best-way-to-have-some-kind-of-state-in-a-custom-module/227084/1 "2013-03-03T22:44:18Z")

</div>

Hello Nginx Gurus,

I’m kind of a newby in nginx plugin development, so trying to understand  
what’s the best way to  
connect to a proprietary backend system (that provides C API) from  
within nginx plugin?

As far as I understand the best way for such issues is to implement  
custom upstream proxy module but it’s  
pretty difficult to understand the low level protocol of the backend  
system, so I need to use the API it provides.

Could you suggest where to place the initialization code/connection code  
to the backend system and where to hold  
the connection (which must be created only once) to the system itself.

Regards,  
Sergey
