Using Redux to serve images on myamiweb » History » Version 37
Amber Herold, 12/16/2013 01:20 PM
1 | 1 | Anchi Cheng | h1. Using Redux to serve images on myamiweb |
---|---|---|---|
2 | |||
3 | 21 | Amber Herold | *Before you begin:* |
4 | Redux is new for CentOS 6 (PHP 5.3). |
||
5 | |||
6 | 1 | Anchi Cheng | h2. Installation |
7 | |||
8 | 33 | Amber Herold | * Install python filesystem abstraction for redux caching: |
9 | 1 | Anchi Cheng | <pre> |
10 | sudo easy_install fs |
||
11 | </pre> |
||
12 | 33 | Amber Herold | * Install Myami packages |
13 | <pre> |
||
14 | cd myami |
||
15 | ./pysetup.sh install |
||
16 | </pre> |
||
17 | * Redux needs write permission at its installation location to write fftw wisdom file. |
||
18 | 6 | Neil Voss | |
19 | 34 | Amber Herold | h2. Configuration |
20 | 1 | Anchi Cheng | |
21 | 16 | Anchi Cheng | h3. configure redux |
22 | 17 | Anchi Cheng | |
23 | 1 | Anchi Cheng | <pre> |
24 | 17 | Anchi Cheng | > cd /YourMyamDownload/redux |
25 | 16 | Anchi Cheng | > cp redux.cfg.template redux.cfg |
26 | 1 | Anchi Cheng | </pre> |
27 | 17 | Anchi Cheng | * You can also copy it to /etc/myami/redux.cfg if you prefer. |
28 | 1 | Anchi Cheng | * Set a writable log path by the user starting it. In this example, we start redux as root and save the log in /var/log/redux.log |
29 | 34 | Amber Herold | * Edit the redux.cfg file as follows: |
30 | 31 | Anchi Cheng | <pre> |
31 | [log] |
||
32 | file: /var/log/redux.log |
||
33 | </pre> |
||
34 | 17 | Anchi Cheng | * Turn on redux caching if desired, |
35 | 1 | Anchi Cheng | <pre> |
36 | 16 | Anchi Cheng | [cache] |
37 | enable: yes |
||
38 | path: /var/cache/myami/redux |
||
39 | disksize: 500 |
||
40 | memsize: 500 |
||
41 | </pre> |
||
42 | 37 | Amber Herold | |
43 | 7 | Neil Voss | *You need to make sure the cache path exists and writable by the user that starts the redux server (reduxd)* |
44 | 35 | Amber Herold | |
45 | 36 | Amber Herold | * Input the desired disk_cache_path, disk_cache_size, and mem_cache_size in the next few lines |
46 | * Create the disk_cache_path before running redux if cache will be used |
||
47 | 37 | Amber Herold | |
48 | 1 | Anchi Cheng | |
49 | h2. Test Installation |
||
50 | |||
51 | # Using Redux to do simple input output (simple client with no reduxd server needed):<pre>redux --filename=test.jpg --oformat=PNG > test.png</pre>Make sure the resulting test.png is in fact an image and not an error message. |
||
52 | # Run the server: run the following on a command line:<pre>reduxd</pre>leave it running for the following... |
||
53 | # Test command line client connecting to the server<pre>redux --server_host=localhost --filename=test.jpg --oformat=PNG > test.png</pre>Note: The input file name is from the perspective of the reduxd server, so be sure to give it an absolute path (unlike the first test, which was not accessing the server) |
||
54 | 31 | Anchi Cheng | # Check the redux.log created as configured in redux.cfg. This contains the port opened by redux server that will allow myamiweb to connect to. |
55 | |||
56 | h2. Assign redux client to connect to redux server in myamiweb |
||
57 | |||
58 | * At myamiweb/config.php |
||
59 | <pre> |
||
60 | define('SERVER_HOST',"localhost") |
||
61 | define('SERVER_PORT',"55123"); |
||
62 | </pre> |
||
63 | *The server port chosen should match the value found in redux.log when the redux server is started* |
||
64 | 2 | Anchi Cheng | |
65 | 26 | Anchi Cheng | h2. Setup fftw to use wisdom (Not yet available for myami-2.2-redux) |
66 | 25 | Anchi Cheng | |
67 | 27 | Anchi Cheng | *This applies only if you see the messge "*** Using custom copy of fftw3"* in the previous redux test. |
68 | |||
69 | 29 | Anchi Cheng | fftw runs much faster on odd image dimension if a wisdom is saved. It is best to create the wisdom ahead of time using the stand alone script pyami/fft/fftwsetup.py. It will store the wisdom you create in your home directory with a name like 'fftw3-wisdom-hostname'. If you only start reduxd as root and fftwsetup.py is run as root, this is enough. |
70 | 1 | Anchi Cheng | |
71 | 29 | Anchi Cheng | * For developer only: you can copy the wisdom file to any other home directory that wants to use it, or copy it as root to a file called /etc/fftw/wisdom which any user can access. |
72 | |||
73 | 1 | Anchi Cheng | h3. Using fftwsetup.py: |
74 | 25 | Anchi Cheng | |
75 | 30 | Anchi Cheng | FIrst, you need to know the typical image dimension redux needs to process, especially the large ones and *ones that are not powers of 2 such as those produced by Gatan K2*. |
76 | 25 | Anchi Cheng | |
77 | <pre> |
||
78 | cd /YourMyamDownload/pyami/fft |
||
79 | ./fftwsetup.py 1 number_of_rows number_of_colums |
||
80 | </pre> |
||
81 | |||
82 | For example, for K2 summit super-resolution image there are 7676 rows and 7420 columns, therefore, the command line is |
||
83 | <pre> |
||
84 | ./fftwsetup.py 1 7676 7420 |
||
85 | </pre> |
||
86 | This may take a few minutes. |
||
87 | |||
88 | Run this for as many dimensions you know will be used and move it for general use as instructed above if preferred. |
||
89 | 1 | Anchi Cheng | |
90 | 32 | Anchi Cheng | h2. Using redux server with myamiweb (recommended) |
91 | 14 | Jim Pulokas | |
92 | 15 | Jim Pulokas | # start reduxd server if not already running from the above test:<pre>reduxd</pre> |
93 | 10 | Neil Voss | # click on "[test dataset]" on your main myamiweb home page, or go directly to the URL: myamiweb/viewerxml.php |
94 | 15 | Jim Pulokas | # test by accessing your own images from Leginon in myamiweb/imageviewer.php |
95 | 11 | Neil Voss | |
96 | h2. starting reduxd at boot |
||
97 | |||
98 | <pre> |
||
99 | sudo cp -v myami/redux/init.d/reduxd /etc/init.d/ |
||
100 | 1 | Anchi Cheng | sudo service reduxd start |
101 | </pre> |
||
102 | 18 | Anchi Cheng | |
103 | 22 | Jim Pulokas | h2. Alternative reduxd installation on file server rather than web server |
104 | |||
105 | This approach is less tested, but has been found necessary in the case of a very high load system (multiple microscopes acquiring data, multiple processing jobs, multiple web clients and servers, etc). The problem has been that all of this demand for image I/O is occuring over NFS, and the NFS server is not coping with the high demand. One solution we have been investigating is to run reduxd directly on the file server rather than the web server. This means reduxd has direct access to the image files (not through NFS) and the web server now accesses reduxd over the network rather than locally. This has two potential benefits: 1) less load on the NFS server, 2) only transferring JPEGs over the network, not MRCs. |
||
106 | |||
107 | How to do it: |
||
108 | |||
109 | # Install required myami components on the file server, at least pyami, sinedon, numextension, redux, leginon, modules, and any other 3rd part packages required by those. |
||
110 | 23 | Jim Pulokas | # (optional) edit init.d/reduxd and use the optional high priority command line (see comment in that file) |
111 | 22 | Jim Pulokas | # Configure redux.cfg on file server and start reduxd |
112 | 23 | Jim Pulokas | # On web server, configure config.php: turn off all caching options, set redux server host to be the file server |
113 | 24 | Jim Pulokas | # skip starting reduxd on the web server |
114 | 23 | Jim Pulokas | # skip imcache as described below, since this also uses redux locally and accesses images over NFS |
115 | 22 | Jim Pulokas | |
116 | 20 | Amber Herold | {{include(leginon:Using imcache to cache mrc images as jpeg images of the default size on myamiweb)}} |