Project

General

Profile

Using Redux to serve images on myamiweb » History » Version 47

Amber Herold, 12/16/2013 02:38 PM

1 1 Anchi Cheng
h1. Using Redux to serve images on myamiweb
2
3 21 Amber Herold
Redux is new for CentOS 6 (PHP 5.3). 
4
5 1 Anchi Cheng
h2. Installation
6
7 33 Amber Herold
* Install python filesystem abstraction for redux caching:
8 1 Anchi Cheng
<pre>
9
sudo easy_install fs
10
</pre>
11 33 Amber Herold
* Install Myami packages
12
<pre>
13
cd myami
14
./pysetup.sh install
15
</pre>
16 1 Anchi Cheng
17 47 Amber Herold
h2. Copy the myami/myamiweb directory to your Apache web directory
18
19
Example:
20
<pre>
21
cd myami
22
23
#CentOS example
24
sudo cp -vr myamiweb /var/www/html/ 
25
26
#this is temporary for setup, revert to 755 when finished with this page
27
sudo chmod 777 /var/www/html/myamiweb  
28
29
#if you have SELinux enabled this command will help
30
sudo chcon -R --type=httpd_sys_content_t /var/www/html
31
</pre>
32
33
34
35
36 34 Amber Herold
h2. Configuration
37 1 Anchi Cheng
38 16 Anchi Cheng
h3. configure redux
39 17 Anchi Cheng
40 1 Anchi Cheng
<pre>
41 17 Anchi Cheng
> cd /YourMyamDownload/redux
42 16 Anchi Cheng
> cp redux.cfg.template redux.cfg
43 1 Anchi Cheng
</pre>
44 44 Amber Herold
45 17 Anchi Cheng
* You can also copy it to /etc/myami/redux.cfg if you prefer.
46 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
47 34 Amber Herold
* Edit the redux.cfg file as follows:
48 44 Amber Herold
&nbsp;
49 31 Anchi Cheng
<pre>
50
[log]
51
file: /var/log/redux.log
52
</pre>
53 44 Amber Herold
&nbsp;
54 43 Amber Herold
* Turn on redux caching if desired:
55 44 Amber Herold
&nbsp;
56 1 Anchi Cheng
<pre>
57 16 Anchi Cheng
[cache]
58
enable: yes
59
path: /var/cache/myami/redux
60
disksize:  500
61 40 Amber Herold
memsize: 500
62 1 Anchi Cheng
</pre>
63 44 Amber Herold
&nbsp;
64
** *You need to make sure the cache path exists and writable by the user that starts the redux server (reduxd)*
65 38 Amber Herold
** Input the desired disk_cache_path, disk_cache_size, and mem_cache_size in the next few lines
66
** Create the disk_cache_path before running redux if cache will be used
67 37 Amber Herold
68 1 Anchi Cheng
69 42 Amber Herold
70 1 Anchi Cheng
h2. Test Installation
71
72
# 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.
73
# Run the server:  run the following on a command line:<pre>reduxd</pre>leave it running for the following...
74
# 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)
75 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.
76
77
h2. Assign redux client to connect to redux server in myamiweb
78
79
* At myamiweb/config.php
80
<pre>
81
define('SERVER_HOST',"localhost")
82
define('SERVER_PORT',"55123");
83
</pre>
84
*The server port chosen should match the value found in redux.log when the redux server is started*
85 2 Anchi Cheng
86 46 Anchi Cheng
h2. Setup fftw to use wisdom (myami-3.0 only)
87 25 Anchi Cheng
88 27 Anchi Cheng
*This applies only if you see the messge "*** Using custom copy of fftw3"* in the previous redux test.
89
90 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.
91 1 Anchi Cheng
92 47 Amber Herold
* Redux needs write permission at its installation location to write fftw wisdom file.
93 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.
94
95 1 Anchi Cheng
h3. Using fftwsetup.py:
96 25 Anchi Cheng
97 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*.
98 25 Anchi Cheng
99
<pre>
100
cd /YourMyamDownload/pyami/fft
101
./fftwsetup.py 1 number_of_rows number_of_colums
102
</pre>
103
104
For example, for K2 summit super-resolution image there are 7676 rows and 7420 columns, therefore, the command line is
105
<pre>
106
./fftwsetup.py 1 7676 7420
107
</pre>
108
This may take a few minutes.
109
110
Run this for as many dimensions you know will be used and move it for general use as instructed above if preferred.
111 1 Anchi Cheng
112 32 Anchi Cheng
h2. Using redux server with myamiweb (recommended)
113 14 Jim Pulokas
114 15 Jim Pulokas
# start reduxd server if not already running from the above test:<pre>reduxd</pre>
115 10 Neil Voss
# click on "[test dataset]" on your main myamiweb home page, or go directly to the URL: myamiweb/viewerxml.php
116 15 Jim Pulokas
# test by accessing your own images from Leginon in myamiweb/imageviewer.php
117 11 Neil Voss
118
h2. starting reduxd at boot
119
120
<pre>
121
sudo cp -v myami/redux/init.d/reduxd /etc/init.d/
122 1 Anchi Cheng
sudo service reduxd start
123
</pre>
124 18 Anchi Cheng
125 22 Jim Pulokas
h2. Alternative reduxd installation on file server rather than web server
126
127
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.
128
129
How to do it:
130
131
# 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.
132 23 Jim Pulokas
# (optional) edit init.d/reduxd and use the optional high priority command line (see comment in that file)
133 22 Jim Pulokas
# Configure redux.cfg on file server and start reduxd
134 23 Jim Pulokas
# On web server, configure config.php:  turn off all caching options, set redux server host to be the file server
135 24 Jim Pulokas
# skip starting reduxd on the web server
136 23 Jim Pulokas
# skip imcache as described below, since this also uses redux locally and accesses images over NFS
137 22 Jim Pulokas
138 20 Amber Herold
{{include(leginon:Using imcache to cache mrc images as jpeg images of the default size on myamiweb)}}