<p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:rgb(255,255,255);clear:both;word-wrap:break-word;font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;line-height:18px">
I worte this python script which acts as an RPC server by modifying the default RPC example in RabbitMQ tutorial found <a href="http://www.rabbitmq.com/tutorials/tutorial-six-python.html" rel="nofollow" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(74,107,130);text-decoration:initial">here</a>. It runs fine in my laptop. But when i run it in an amazon ec2 High CPU Medium Instance with these specs :</p>
<blockquote style="margin:0px 0px 10px;padding:10px 10px 1px;border:0px;font-size:14px;vertical-align:baseline;background-color:rgb(238,238,238);quotes:none;font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;line-height:18px">
<p style="margin:0px 0px 1em;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;clear:both;word-wrap:break-word">1.7 GiB of memory</p><p style="margin:0px 0px 1em;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;clear:both;word-wrap:break-word">
5 EC2 Compute Units (2 virtual cores with 2.5 EC2 Compute Units each)</p><p style="margin:0px 0px 1em;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;clear:both;word-wrap:break-word">350 GB of instance storage</p>
</blockquote><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:rgb(255,255,255);clear:both;word-wrap:break-word;font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;line-height:18px">
It takes up 100% CPU. Although my laptop with almost the same config runs this with less than 4% CPU use.I run this in Ubuntu-12.04 in both my laptop and amazon.</p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:rgb(255,255,255);clear:both;word-wrap:break-word;font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;line-height:18px">
Here is my code</p><pre class="default prettyprint prettyprinted" style="margin-top:0px;margin-bottom:10px;padding:5px;border:0px;font-size:14px;vertical-align:baseline;background-color:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;overflow:auto;width:auto;max-height:600px;line-height:18px">
<code style="margin:0px;padding:0px;border:0px;vertical-align:baseline;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif"><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> </span><span class="com" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:gray">#!/usr/bin/env python</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
</span><span class="kwd" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,139)">import</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> pika
</span><span class="kwd" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,139)">import</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> commands
</span><span class="kwd" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,139)">import</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> socket
</span><span class="kwd" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,139)">import</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> base64
connection </span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">=</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> pika</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">.</span><span class="typ" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175)">BlockingConnection</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">(</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">pika</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">.</span><span class="typ" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175)">ConnectionParameters</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">(</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
host</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">=</span><span class="str" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(128,0,0)">'localhost'</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">))</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
channel </span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">=</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> connection</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">.</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">channel</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">()</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
channel</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">.</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">queue_declare</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">(</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">queue</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">=</span><span class="str" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(128,0,0)">'rpc_queue'</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">)</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
</span><span class="kwd" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,139)">def</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> on_request</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">(</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">ch</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">,</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> method</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">,</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> props</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">,</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> body</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">):</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
</span><span class="com" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:gray">#print body</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
body </span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">=</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> base64</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">.</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">b64decode</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">(</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">body</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">)</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
</span><span class="kwd" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,139)">print</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> body
run </span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">=</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> commands</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">.</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">getoutput</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">(</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">body</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">)</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
response </span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">=</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> socket</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">.</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">gethostname</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">()</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
</span><span class="kwd" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,139)">print</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> response
ch</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">.</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">basic_publish</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">(</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">exchange</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">=</span><span class="str" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(128,0,0)">''</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">,</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
routing_key</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">=</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">props</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">.</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">reply_to</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">,</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
properties</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">=</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">pika</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">.</span><span class="typ" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175)">BasicProperties</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">(</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">correlation_id </span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">=</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> \
props</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">.</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">correlation_id</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">),</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
body</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">=</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">str</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">(</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">response</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">))</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
ch</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">.</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">basic_ack</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">(</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">delivery_tag </span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">=</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> method</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">.</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">delivery_tag</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">)</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
channel</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">.</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">basic_qos</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">(</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">prefetch_count</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">=</span><span class="lit" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(128,0,0)">1</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">)</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
channel</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">.</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">basic_consume</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">(</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">on_request</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">,</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> queue</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">=</span><span class="str" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(128,0,0)">'rpc_queue'</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">)</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
</span><span class="kwd" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,139)">print</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> </span><span class="str" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(128,0,0)">" [x] Awaiting RPC requests"</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
channel</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">.</span><span class="pln" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">start_consuming</span><span class="pun" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">()</span></code></pre>
<p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:rgb(255,255,255);clear:both;word-wrap:break-word;font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;line-height:18px">
How can i fix this ?</p><div><br></div>Manu