b25b00d2 |
1 | ========================================= |
2 | Considerations for Production Deployments |
3 | ========================================= |
4 | |
5 | This document contains a number of suggestions for deploying |
6 | MediaGoblin in actual production environments. Consider |
7 | ":doc:`deploying`" for a basic overview of how to deploy Media |
8 | Goblin. |
9 | |
a085dda5 |
10 | Deploy with Paste |
11 | ----------------- |
12 | |
13 | The instance configured with ``./lazyserver.sh`` is not ideal for a |
14 | production MediaGoblin deployment. Ideally, you should be able to use |
15 | an "init" or "control" script to launch and restart the MediaGoblin |
16 | process. |
17 | |
18 | Use the following command as the basis for such a script: :: |
19 | |
20 | CELERY_ALWAYS_EAGER=true \ |
21 | /srv/mediagoblin.example.org/mediagoblin/bin/paster serve \ |
22 | /srv/mediagoblin.example.org/mediagoblin/paste.ini \ |
23 | --pid-file=/var/run/mediagoblin.pid \ |
24 | --server-name=fcgi fcgi_host=127.0.0.1 fcgi_port=26543 \ |
25 | |
26 | The above configuration places MediaGoblin in "always eager" mode |
27 | with Celery, this means that submissions of content will be processed |
28 | synchronously, and the user will advance to the next page only after |
29 | processing is complete. If we take Celery out of "always eager mode," |
30 | the user will be able to immediately return to the MediaGoblin site |
31 | while processing is ongoing. In these cases, use the following command |
32 | as the basis for your script: :: |
33 | |
34 | CELERY_ALWAYS_EAGER=false \ |
35 | /srv/mediagoblin.example.org/mediagoblin/bin/paster serve \ |
36 | /srv/mediagoblin.example.org/mediagoblin/paste.ini \ |
37 | --pid-file=/var/run/mediagoblin.pid \ |
38 | --server-name=fcgi fcgi_host=127.0.0.1 fcgi_port=26543 \ |
39 | |
40 | Separate Celery |
41 | --------------- |
b25b00d2 |
42 | |
43 | While the ``./lazyserer.sh`` configuration provides an efficient way to |
44 | start using a MediaGoblin instance, it is not suitable for production |
45 | deployments for several reasons: |
46 | |
a085dda5 |
47 | In nearly every scenario, work on the Celery queue will need to |
48 | balance with the demands of other processes, and cannot proceed |
49 | synchronously. This is a particularly relevant problem if you use |
50 | MediaGoblin to host video content. Processing with Celery ought to be |
51 | operationally separate from the MediaGoblin application itself, this |
52 | simplifies management and support better workload distribution. |
b25b00d2 |
53 | |
a085dda5 |
54 | Basically, if you're doing anything beyond a trivial workload, such as |
55 | image hosting for a small set of users, or have limited media types |
56 | such as "ASCII art" or icon sharing, you will need to run ``celeryd`` |
57 | as a separate process. |
b25b00d2 |
58 | |
59 | Build an :ref:`init script <init-script>` around the following |
60 | command. |
61 | |
62 | CELERY_CONFIG_MODULE=mediagoblin.init.celery.from_celery ./bin/celeryd |
63 | |
64 | Modify your existing MediaGoblin and application init scripts, if |
65 | necessary, to prevent them from starting their own ``celeryd`` |
66 | processes. |
67 | |
68 | .. _init-script: |
69 | |
70 | Use an Init Script |
a085dda5 |
71 | ------------------ |
72 | |
73 | Look in your system's ``/etc/init.d/`` or ``/etc/rc.d/`` directory for |
74 | examples of how to build scripts that will start, stop, and restart |
75 | MediaGoblin and Celery. These scripts will vary by |
76 | distribution/operating system. In the future, MediaGoblin will provide |
77 | example scripts as examples. |
78 | |
79 | .. TODO insert init script here |
80 | .. TODO are additional concernts ? |
81 | .. Other Concerns |
82 | .. -------------- |