CPU Steal Time

Today morning, I was monitoring two EC2 AMI’s for their performance under load conditions for one applications in office. I was doing it in the most rudementary method, by obeserving the output from ‘top’. The last parameter in the CPU information line, ‘st’, drew my attention immediately as it was consuming nearly 60% of CPU time!

1:Def - 22:52:40 up 15:20,  1 user,  load average: 7.07, 3.30, 1.44
 Tasks: 110 total,   5 running, 105 sleeping,   0 stopped,   0 zombie
 Cpu(s): 30.9%us,  7.3%sy,  3.7%ni,  0.0%id,  0.0%wa,  0.0%hi, 0.0%si, 58.1%st
 Mem:   1747764k total,  1687264k used,    60500k free,    34288k buffers
 Swap:   917496k total,       88k used,   917408k free,   538928k cached

I guess I had missed it or never paid attention to that parameter earlier. Googled a little to find out that ‘st’ = ‘steal’, in the literal sense.

Steal time is the percentage of time a virtual CPU waits for a real CPU while the hypervisor is not scheduling this virtual CPU.

I found a very nice presentation from IBM, which explains what steal time is and why it exists –> http://t.co/XNhOIan

Filed under  //   AWS   Amazon   CPU   EC2   Steal Time   Technology   kernel   linux  

Grounding the Apple plug!

When Apple ships their products to India I wonder why they cannot provide 3 pin India compatible plug?

Anyways, here comes the Indian jugaad to rescue! I took one pin of a broken 3 pin adapter & plugged it into another 3 pin international converter adapter. This pin can be aligned to coincide with the earthing or grounding plate of the plug provided by Apple. See attached photos for better understanding.

Filed under  //   Apple   Macbook Pro   Power adapter   Random Thoughts   Technology  

Configure Apache Reverse Proxy on Mac

Following up on the previous posts on configuring apache on Ubuntu, I now post the method to do the same on the Mac.

Step 1: You will need to download the mod_proxy_html module from http://apache.webthing.com/mod_proxy_html/

Step 2: Compile the code.

$ sudo apxs -ci -I /usr/include/libxml2 mod_xml2enc.c
$ sudo apxs -ci -I /usr/include/libxml2 -I . mod_proxy_html.c

Then update you httpd.conf to include

LoadFile /usr/lib/libxml2.dylib
LoadModule  proxy_html_module   libexec/apache2/mod_proxy_html.so
LoadModule  xml2enc_module   libexec/apache2/mod_xml2enc.so

Also take a look at the proxy-httpd.conf file that ships with mod_proxy_html for additional config you may want.

Filed under  //   Apache2   Apple OS X   Technology   mac  

Apache2 reverse proxy with SSL

Following up on the last post, here I am outlining how to make reverse
proxy work with SSL,

$ sudo a2enmod ssl*

to enable all Apache SSL modules.
After this I appended the following code in the file
/etc/apache2/sites-available/default-ssl
 
 AddDefaultCharset off 
 Order deny,allow 
 Allow from all 
 
SSLProxyEngine on 
SSLProxyCACertificateFile /etc/apache2/cacerts.crt 
ProxyPass /abc https://xxx.xxx.xx.xx:4400/abc 
ProxyPassReverse /abc https://xxx.xxx.xx.xx:4400/abc 
ProxyVia off

Since I was re-directing to a secure server, I faced two errors:
[error] [client xxx.xxx.xx.xx] SSL Proxy requested for 
127.0.1.1:443 but not enabled [Hint: SSLProxyEngine] 
[error] proxy: HTTPS: failed to enable ssl support for 
xxx.xxx.xx.xx:4400 (xxx.xxx.xx.xx)

The main reasons being, first I had forgotten to add the
SSLProxyEngine parameter to the configuration.
Secondly, when apache acts as a proxy, it acts like a client
requesting over SSL. Hence it needs the server certificate (PEM
encoded) to do a successful handshake.
Using openSSL,
openssl s_client -connect xxx.xxx.xx.xx:4400 -showcerts

Copied the encoded content from -----BEGIN CERTIFICATE----- & -----END
CERTIFICATE----- , saved it to cacerts.crt.
After this apache started serving SSL access to remote server via proxy.

Filed under  //   Apache2   Technology   ubuntu 11.04  

Apache reverse proxy using mod_proxy

In the current project, we are using GWT on the front end and Django
on the back-end. To avoid SOP (Same Origin Policy) related issues, the
GWT code and the Django code has to be served from the same server. To
work around this problem, we setup a local (development machine)
Apache server, with reverse proxy.

http://localhost/abc was mapped to http://remote_aws_ip:8888/abc

To do this, follow the steps below:

 
$ sudo apt-get install libapache2-mod-proxy-html 
$ sudo a2enmod proxy* 
 

Create a new file, remote_aws_ip, inside /etc/apache2/sites-available

 
<VirtualHost 127.0.0.1:80> 
 DocumentRoot "/var/www" 
 ServerName remote_aws_ip 
 <Proxy *> 
 AddDefaultCharset off 
 Order deny,allow 
 Allow from all 
 </Proxy> 
 
 ProxyPass /abc http://remote_aws_ip:8888/hcm 
 ProxyPassReverse /abc http://remote_aws_ip:8888.com/hcm 
 ProxyVia off 
</VirtualHost> 

Then enable the site, by running

$ sudo a2ensite remote_aws_ip 

This will make a symlink to the file into sites-enabled.

Last but not the least

$ sudo service apache2 restart

Now I point my browser to http://localhost/abc and it fetches content
from http://remote_aws_ip:8888/abc

Filed under  //   Apache2   Technology   ubuntu 11.04  

Python Virtualenv Error: "--always-copy -U distribute failed with error code 1"

Faced the following error while initialising a virtualenv instance on ubuntu 11.04:

aditya@TR:~$ virtualenv virtualenvs/env_selenium --no-site-packages
New python executable in virtualenvs/env_selenium/bin/python
Installing distribute................................
  Complete output from command /home/aditya/virtualenvs/env_s...ython -c "#!python
\"\"\"Bootstrap distribu...1:])
" --always-copy -U distribute:
  Extracting in /tmp/tmptp7iU4
Traceback (most recent call last):
  File "<string>", line 477, in <module>
  File "<string>", line 473, in main
  File "<string>", line 74, in _install
  File "<string>", line 444, in _extractall
  File "/usr/lib/python2.7/tarfile.py", line 2083, in extract
    self._extract_member(tarinfo, os.path.join(path, tarinfo.name))
  File "/usr/lib/python2.7/tarfile.py", line 2159, in _extract_member
    self.makefile(tarinfo, targetpath)
  File "/usr/lib/python2.7/tarfile.py", line 2199, in makefile
    copyfileobj(source, target)
  File "/usr/lib/python2.7/tarfile.py", line 266, in copyfileobj
    shutil.copyfileobj(src, dst)
  File "/usr/lib/python2.7/shutil.py", line 48, in copyfileobj
    buf = fsrc.read(length)
  File "/usr/lib/python2.7/tarfile.py", line 817, in read
    buf += self.fileobj.read(size - len(buf))
  File "/usr/lib/python2.7/tarfile.py", line 735, in read
    return self.readnormal(size)
  File "/usr/lib/python2.7/tarfile.py", line 744, in readnormal
    return self.fileobj.read(size)
  File "/usr/lib/python2.7/gzip.py", line 252, in read
    self._read(readsize)
  File "/usr/lib/python2.7/gzip.py", line 299, in _read
    self._read_eof()
  File "/usr/lib/python2.7/gzip.py", line 338, in _read_eof
    hex(self.crc)))
IOError: CRC check failed 0xbf8917c9L != 0x59a4e93eL
----------------------------------------
...Installing distribute...done.
Traceback (most recent call last):
  File "/usr/bin/virtualenv", line 3, in <module>
    virtualenv.main()
  File "/usr/lib/pymodules/python2.7/virtualenv.py", line 536, in main
    use_distribute=options.use_distribute)
  File "/usr/lib/pymodules/python2.7/virtualenv.py", line 626, in create_environment
    install_distribute(py_executable, unzip=unzip_setuptools)
  File "/usr/lib/pymodules/python2.7/virtualenv.py", line 367, in install_distribute
    _install_req(py_executable, unzip, distribute=True)
  File "/usr/lib/pymodules/python2.7/virtualenv.py", line 339, in _install_req
    cwd=cwd)
  File "/usr/lib/pymodules/python2.7/virtualenv.py", line 597, in call_subprocess
    % (cmd_desc, proc.returncode))
OSError: Command /home/aditya/virtualenvs/env_s...ython -c "#!python
\"\"\"Bootstrap distribu...1:])


" --always-copy -U distribute failed with error code 1

Hunting around the web realised the issue was with the replacement of setuptools with distribute. To get rid of the issue, updated virtualenv installation.

$ sudo pip install pip --upgrade
$ sudo pip install virtualenvwrapper --upgrade

Filed under  //   Code   Python   Technology  

About

A software professional & an amateur wildlife photographer

Tumblr