ZxMobile + NginX = High battery consuming
Results 1 to 5 of 5

Thread: ZxMobile + NginX = High battery consuming

  1. #1
    Active Member
    Join Date
    Mar 2014
    Posts
    15

    Question ZxMobile + NginX = High battery consuming

    Hello,

    Code:
    OS : Ubuntu Server 12.04.4 LTS 64bits
    Kernel : 3.2.0-60-generic
    Zimbra : Release 8.0.6.GA.5922.UBUNTU12.64 UBUNTU12_64 FOSS edition
    ZeXtras : 1.8.13
    Apache : 2.2.22 Prefork
    We used to have an Apache reverse proxy behind our Zimbra server and for several reasons, we had to remove it and use the Zimbra embedded NginX as reverse proxy (which should be good since it's provided by Zimbra itself).

    With Apache, we had no issue with mobile phones + ActiveSync (in push mode) but as soon as we switched to NginX, all our mobile devices configured in push mode began to consume a lot of battery (about twice more than before)

    With Apache (and same with NginX), our network architecture is as below :

    Code:
    Internet ----- a.b.c.d:443 -----> RP (with SSL) ----- 127.0.0.1:7080 -----> Zimbra (Jetty)
    Apache configuration used to be :

    Code:
    ServerLimit         512
    StartServers         16
    MinSpareServers      16
    MaxSpareServers      32
    MaxClients          256
    MaxRequestsPerChild  16
    
    Listen a.b.c.d:443
    Timeout 1800
    UseCanonicalName Off
    ServerSignature Off
    
    KeepAlive On
    KeepAliveTimeout 15
    MaxKeepAliveRequests 128
    
    ProxyTimeout 1800
    ProxyPreserveHost On
    
    SSLEngine on
    SSLCACertificateFile  ca.crt
    SSLCertificateFile    server.crt
    SSLCertificateKeyFile server.key
    
    RewriteEngine On
    RewriteRule ^/(.*) http://localhost:7080/$1 [P]


    Now, NginX configuration is (which is mostly the default configuration provided by Zimbra) :

    Code:
    http
    {
      server_tokens off;
      server_names_hash_max_size    512;
      server_names_hash_bucket_size 64;
    
      proxy_read_timeout 60s;
      proxy_send_timeout 60s;
    
      chunkin on;
      tcp_keepalive on;
    
      upstream zimbra
      {
        server    localhost:7080 fail_timeout=60s;
        zmauth;
      }
    
      server
      {
        listen                    a.b.c.d:443;
        client_max_body_size      0;
        ssl                       on;
        ssl_prefer_server_ciphers on;
        ssl_ciphers               !SSLv2:!MD5:HIGH;
        ssl_certificate           server.chain.crt;
        ssl_certificate_key       server.key;
    
        location ^~ /Microsoft-Server-ActiveSync
        {
          set $mailhostport 7080;
          set $relhost $host;
    
          if ($mailhostport != 80)
          {
            set $relhost $host:$mailhostport;
          }
    
          proxy_pass          http://zimbra;
          proxy_read_timeout  3600;
          proxy_buffering     off;
          proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
    
          set $virtual_host $http_host;
          if ($virtual_host = '')
          {
            set $virtual_host $server_addr:$server_port;
          }
    
          proxy_set_header Host            $virtual_host;
          proxy_redirect http://$http_host/ https://$http_host/;
          proxy_redirect http://$relhost/ https://$http_host/;
        }
      }
    }
    I can't figure out why with NginX, mobile batteries are dumped that much.

    I analysed network frames and I could notice a difference between Apache and NginX : NginX works in HTTP/1.0 where Apache uses HTTP/1.1 due to the "KeepAlive on" statement. I tried to turn on KeepAlive on NginX :

    Code:
    [...]
    
      upstream zimbra
      {
        server    localhost:7080 fail_timeout=60s;
        keepalive 2048;
        zmauth;
      }
    
    [...]
    
        location ^~ /Microsoft-Server-ActiveSync
        {
          proxy_http_version 1.1;
          proxy_set_header Connection "";
          keepalive_timeout 15;
    [...]
    But it changes nothing. I tried to turn off and on mobiles, I tried to delete and setup again accounts on mobiles, nothing works, batteries are dumped.

    Any help would be greatly appreciated

    Thanks
    Regards

  2. #2
    Active Member
    Join Date
    Mar 2014
    Posts
    15
    I quickly reply to myself regarding HTTP/1.0. This is a mistake from my side, I messed up with all my tcpdumps

    Actually, I've tested several parameters such as keepalive_timeout, keepalive_requests, ... but nothing changes.

    Last night, my iPhone 4 consumed 50% of battery in less than 8 hours, this is 4 times more than usually...

    Today, I reverted to the Zimbra's default NginX configuration, and I'm running a test just with "proxy_buffering off" commented out in section "location ^~ /Microsoft-Server-ActiveSync" because, by default, Apache mod_proxy buffers output (ProxyIOBufferSize)...

    Thanks
    Regards

  3. #3
    ZeXtras Community Manager ZeXtras Employee Cine's Avatar
    Join Date
    Apr 2011
    Posts
    2,360
    Hello Niko!

    The first thing that comes to my mind is to try raising the connection timeout value to a much higher value, such as 30 minutes, to avoid ping requests being truncated and reinstated too many times thus draining the device's battery.
    Something similar has recently happened with the ZeXtras Chat Zimlet to another user on this forums, so this might be worth a try...

    Another thing to check is item looping: please have a look at the /opt/zimbra/log/sync.log file and make sure that no itemsID appear multiple times for the same user (e.g. the same, badly formatted email has been sent to most/all users).

    Have a nice day,
    Cine
    the ZeXtras Team

  4. #4
    Active Member
    Join Date
    Mar 2014
    Posts
    15
    Hell Cine,

    Thank you for your reply.

    I don't see what kind of timeout I could setup. There is already the statement "proxy_read_timeout 3600;" defined by default in NginX, which look equivalent to the "ProxyTimeout" statement of Apache. I can't find any other timeout statement in the nginx doc which could help me.

    Thanks
    Regards

  5. #5
    Active Member
    Join Date
    Mar 2014
    Posts
    15
    Hello,

    Well, afer many many tries, I give up using NginX for ActiveSync. I finally added a second set of IPs to the server and I use different subdomains for mobiles (going thru Apache) and non/mobiles (going thru NginX).

    With NginX, my iPhone was consuming 40% of battery during the night. Last night, after I switched back to Apache, it consumed 1%...

    Just incredible...

    Regards

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •