# Connection Pooling
Updated: 1/18/2022, 5:31:44 PM
Created: 1/18/2022, 5:31:44 PM
Last Updated By: dependabot[bot]
Read Time: 2 minute(s)
Connection pooling is a technique where you limit the number of concurrent connections to your back end service. Users are not given an error page although and are pooled and are given connections as they are available. This is done in multiple products as you may have resource restrictions (number of user licenses for example) and even more important performance can actually be decreased when you allow too many concurrent processes.
With MVConnect we decided to not build in connection pooling and instead recommend using off the shelf products. In fact, we recommend never putting the MVConnector web server directly on the internet and instead it should always be proxied behind another webserver/proxy. This is the recommend Tomcat, Node and other Frameworks recommend.
Apache has a mod_proxy module that can reverse proxy and create connection pools. The connection pooling feature apparently only works on certain Apache versions due to something called MPM and/or Prefork.
ProxyRequests Off ProxyTimeout 60 ProxyVia on ProxyPass "/api" "http://127.0.0.1:8180/api" max=5
In this example we are telling Apache any request to /API is to be sent to MVConnector (if you are jBase the default port is 20002). The max setting on the end tells Apache to use connection pooling and to not allow more than 5 concurrent calls. Again this feature appears to not work on some Apache configurations due to process vs thread configurations. The reverse-proxy directive although should work.
NGINX is a newer webserver competing now with Apache. It is thread-based and in many ways faster than Apache. The ngx_http_upsream_module (opens new window) does the same thing as the Apache mod_proxy. Connection pooling appears to be only available now in the commercial product. See the link above for the max_conns directive.
HAProxy (opens new window) is a standalone Linux based proxy server that is free and does have connection pooling. Haproxy can be installed on Centos with yum: yum install HAProxy.
Here is a simple config file and HAProxy running.
[[email protected] haproxy]# cat haproxy.cfg global maxconn 256 defaults log global mode http option httplog option dontlognull retries 3 option redispatch timeout connect 5000 timeout client 10000 timeout server 10000 frontend httptraffic bind *:80 default_backend servers backend servers server web1 127.0.0.1:8180 maxconn 5 [[email protected] haproxy]# haproxy -f haproxy.cfg -db -V
In this example, we have HAProxy listening on 80 (this only works if Apache is not running). It will proxy calls to MVConnect and will limit concurrent connections to 5. You could also proxy HAproxy behind Apache or IIS.
Back to MV Connect Manual