title: Mosquitto increasing maximum connection limit
body: <p>I am trying to increase the maximum open file connection of Mosquitto broker. But I read that increasing concurrent connections are not controlled by Mosquitto only.
  As per our study we decided for 100k concurrent connection, we are targeting 1.6 GB RAM.  But for testing I have to increase from default 1024 connections to 20000
  Testing environment configurations:
  t2. micro AWS server with  64 MB 14.04 ubuntu operating system. Changing connection limit in the mosquitto configuration is not reflecting. What can be the reason? 
  Do we need to change any configuration related to AWS Server?</p>
  
  <p>My configurations:</p>
  
  <p>Our system wide open connections is configured on <code>/etc/sysctl.conf</code>:</p>
  
  <pre><code>fs.file-max =99905
  </code></pre>
  
  <p>Running the command <code>sysctl -p</code> or <code>cat /proc/sys/fs/file-max</code> is reflecting the changes </p>
  
  <p>In <code>/etc/security/limits.conf</code>:</p>
  
  <pre><code>ubuntu          hard     nofile         45000
  ubuntu          soft     nofile         35000
  </code></pre>
  
  <p>Mosquitto is installed under the user 'Ubuntu' .</p>
  
  <p>We also added below line of code on <code>/etc/pam.d/common-session</code></p>
  
  <pre><code>session required pam_limits.so
  </code></pre>
  
  <p>Running <code>ulimit -a</code> is giving the below result:</p>
  
  <pre><code>core file size          (blocks, -c) 0
  data seg size           (kbytes, -d) unlimited
  scheduling priority             (-e) 0
  file size               (blocks, -f) unlimited
  pending signals                 (-i) 7859
  max locked memory       (kbytes, -l) 64
  max memory size         (kbytes, -m) unlimited
  open files                      (-n) 35000
  pipe size            (512 bytes, -p) 8
  POSIX message queues     (bytes, -q) 819200
  real-time priority              (-r) 0
  stack size              (kbytes, -s) 8192
  cpu time               (seconds, -t) unlimited
  max user processes              (-u) 7859
  virtual memory          (kbytes, -v) unlimited
  file locks                      (-x) unlimited
  </code></pre>
  
  <p>My init configuration file for mosquitto in <code>/etc/init/mosquitto.conf</code></p>
  
  <pre><code>description "Mosquitto MQTTv3.1 broker"
  author "Roger Light &lt;roger@atchoo.org"
  
  start on net-device-up
  
  respawn
  
  exec /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
  #limit nofile 4096 4096
  
  limit nofile 24000  24000
  </code></pre>
  
  <p>Below is the configuration in <code>/etc/mosquitto/mosquitto.conf</code>:      </p>
  
  <pre><code># change user to root
  user ubuntu         
  
  set_ulimit () {
      ulimit -f unlimited
      ulimit -t unlimited
      ulimit -v unlimited
      ulimit -n 24000
      ulimit -m unlimited
      ulimit -u 24000
  }
  
  start)
      ...
      # Update ulimit config in start command
      set_ulimit
      ...
      ;;
    stop)
  </code></pre>
  
  <p>But running <code>cat /proc/4957/limits</code> is still showing default value 1024 open files:</p>
  
  <pre><code>Limit                     Soft Limit           Hard Limit           Units
  Max cpu time              unlimited            unlimited            seconds
  Max file size             unlimited            unlimited            bytes
  Max data size             unlimited            unlimited            bytes
  Max stack size            8388608              unlimited            bytes
  Max core file size        0                    unlimited            bytes
  Max resident set          unlimited            unlimited            bytes
  Max processes             7859                 7859                 processes
  Max open files            1024                 4096                 files
  Max locked memory         65536                65536                bytes
  Max address space         unlimited            unlimited            bytes
  Max file locks            unlimited            unlimited            locks
  Max pending signals       7859                 7859                 signals
  Max msgqueue size         819200               819200               bytes
  Max nice priority         0                    0
  Max realtime priority     0                    0
  Max realtime timeout      unlimited            unlimited            us
  </code></pre>
  
  <p>4957 -is the process id of Mosquitto</p>