Menu

best way to setup an iipsrv instance

njfranck
2020-10-27
2020-10-28
  • njfranck

    njfranck - 2020-10-27

    What is the best way to setup a list of iipsrv instances?

    What I've done so far, on a centos 7 server:

    • create a systemd file, that starts the iipsrv.fcgi with spawn-fcgi:
    [Unit]
    Description=iipsrv
    After=network.target
    
    [Service]
    Type=forking
    EnvironmentFile=/etc/sysconfig/iipsrv.conf
    ExecStart=/bin/spawn-fcgi -f /usr/lib/cgi-bin/iipsrv.fcgi -U iip -u iip -a 127.0.0.1 -p 9000 -P /var/run/iipsrv.pid
    PIDFile=/var/run/iipsrv.pid
    Restart=always
    
    [Install]
    WantedBy=multi-user.target
    
    • create multiple servers, each with only this iipsrv.fcgi on port 9000
    • put load balancer like nginx in front of this ensemble

    What I've noticed:

    • when the server has multiple cpu cores, there is an equal number of iipsrv instances. Otherwise, it is just a single process. It this done by spawn-fcig, or is this local decision by iipsrv? It looks like there is a single master process, and n - 1 children (n = number of cores).
    • when I start iipsrv with option "-F 10" from spawn-fcgi, 10 separate iipsrv instances are created, and it looks like incoming requests are distributed among them. But I cannot see who is doing this delegation. One of the processes? spawn-fcgi not, because that process disappears from sight .. Not sure if this is intended use. Is it even needed to start multiple instances to have parallel processing?

    Any idea?

    Thanks in advance.

     
  • Ruven

    Ruven - 2020-10-28

    when the server has multiple cpu cores, there is an equal number of iipsrv instances

    iipsrv does threading internally for its various image processing routines through OpenMP, so this is probably what you are seeing here.

    when I start iipsrv with option "-F 10" from spawn-fcgi, 10 separate iipsrv instances are created

    When you use -F it's spawn-fcgi which does the delegation and load-balancing. Normally, the spawn-fcgi process should remain alive to handle this.

    If you want to start multiple instances, spawn-fcgi is a good solution. You can start iipsrv instances directly and without spawn-fcgi, but in that case each instance will need to be bound to a different port.

    An alternative solution to using systemd is supervisor, which can also be used to start multiple iipsrv instances on a single port. There's information on how to do this in the server documentation: https://iipimage.sourceforge.io/documentation/server/#process

    But are you sure you really need 10 instances of iipsrv? Before doing this, make sure you are using things like Memcached and try to determine what, if anything, is causing any slowness in the system. Often IO on iipsrv will be disk-bound rather than CPU-bound, so having extra instances won't necessarily help.

     
  • njfranck

    njfranck - 2020-10-28

    No, I do not really need 10 instances on the same server. I was just trying to understand the different options ;-)

    This is the situation on my server

    [root@pamuk0 DEVELOPMENT njfranck]# ps aux | grep spawn
    root     29409  0.0  0.0 112708   976 pts/0    S+   15:38   0:00 grep --color=auto spawn
    [root@pamuk0 DEVELOPMENT njfranck]# ps aux | grep iipsrv
    root     29416  0.0  0.0 112708   976 pts/0    S+   15:38   0:00 grep --color=auto iipsrv
    iip      31866  0.0  0.1  35916  4584 ?        Ss   03:19   0:00 /usr/lib64/cgi-bin/iipsrv.fcgi
    iip      31867  0.0  0.1  35912  4592 ?        Ss   03:19   0:00 /usr/lib64/cgi-bin/iipsrv.fcgi
    iip      31868  0.0  0.1  35536  4200 ?        Ss   03:19   0:00 /usr/lib64/cgi-bin/iipsrv.fcgi
    iip      31869  0.0  0.1  35544  4220 ?        Ss   03:19   0:00 /usr/lib64/cgi-bin/iipsrv.fcgi
    [root@pamuk0 DEVELOPMENT njfranck]# systemctl status iipsrv
     iipsrv.service - iipsrv
       Loaded: loaded (/etc/systemd/system/iipsrv.service; enabled; vendor preset: disabled)
       Active: active (running) since Wed 2020-10-28 03:19:01 CET; 12h ago
      Process: 31865 ExecStart=/bin/spawn-fcgi -f $IIP_SRV -U $IIP_USER -u $IIP_USER -a $IIP_HOST -p $IIP_PORT -P $PIDFILE -F 4 (code=exited, status=0/SUCCESS)
     Main PID: 31866 (iipsrv.fcgi)
       CGroup: /system.slice/iipsrv.service
               ├─31866 /usr/lib64/cgi-bin/iipsrv.fcgi
               ├─31867 /usr/lib64/cgi-bin/iipsrv.fcgi
               ├─31868 /usr/lib64/cgi-bin/iipsrv.fcgi
               └─31869 /usr/lib64/cgi-bin/iipsrv.fcgi
    
    Oct 28 03:19:01 pamuk0.ugent.be systemd[1]: Stopped iipsrv.
    Oct 28 03:19:01 pamuk0.ugent.be systemd[1]: Starting iipsrv...
    Oct 28 03:19:01 pamuk0.ugent.be spawn-fcgi[31865]: spawn-fcgi: child spawned successfully: PID: 31866
    Oct 28 03:19:01 pamuk0.ugent.be spawn-fcgi[31865]: spawn-fcgi: child spawned successfully: PID: 31867
    Oct 28 03:19:01 pamuk0.ugent.be spawn-fcgi[31865]: spawn-fcgi: child spawned successfully: PID: 31868
    Oct 28 03:19:01 pamuk0.ugent.be spawn-fcgi[31865]: spawn-fcgi: child spawned successfully: PID: 31869
    Oct 28 03:19:01 pamuk0.ugent.be systemd[1]: Started iipsrv.
    [root@pamuk0 DEVELOPMENT njfranck]# 
    

    So spawn-fcgi has spawned a list of iipsrv instances, but ends itself.
    I debugged with strace to look if all of these instances receive requests,
    and they do, and not all at once, but only one at a time, so someone is
    doing delegation, and it is not spawn-fcgi...

     

Anonymous
Anonymous

Add attachments
Cancel