[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Reduce CPU time on AIX system

Posted on 2009-12-16
5
Medium Priority
?
535 Views
Last Modified: 2013-12-20
Hi,

I need some help of writing a script file to be execute on AIX system.

Let me describe the situation and the problem.

I am having a program which will write a lot of messages to a database tables for every single database connection when user is doing any transaction. I could have many concurrent connections.  However, I have given user an option to write the message to a file on disk instead of to the database table if the program detects the existence of a script file (see the below) in the system. The problem is that the CPU usage was quite high (50% usage) if this option is available (i.e. the script file exist). Now, my question is how to (or if there is a way to) write messages to a memory and then write it to the file periodically (say every 5 minutes) instead of my script  (below) which write to the file for every message.  Thank you.

set -a
set -u

echo $@ >> /home/logs/systemlog.log;

exit 0
0
Comment
Question by:tommym121
  • 3
  • 2
5 Comments
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 26072995
Hi,
are you able to determine what is actually causing the high CPU usage when the script is being called?
It seems obviously so that running your script would cost much less CPU than writing to a database table.
There must be some other problem (maybe in the program calling the script).
Writing to memory only by means of a shell script is not really possible. The only way for a shell script (let aside languages like perl etc.where things should be different) is to create variables (e.g. arrays). But how would you flush their contents to disk in a consistent manner?
Even if one could develop such a method, why would you think that it should cost less CPU time than your simple script?
Try to find out where the CPU consumption really does result from. Use topas or nmon for that purpose. I bet that your script will not be the culprit!
wmp
 
0
 

Author Comment

by:tommym121
ID: 26075310
Hi,

Thank you for the comment.

Actually, I did do an analysis of the cpu usage using vmstat. I also think that the problem is not
on the script. Probably, it is not a problem at all. But, I have trouble to convince myself. The CPU usage is at about 40%. From the vmstat the wait time is 0%, user time is 12%, system time is 19%, remaing 69% is for the idle time. So, I think the cpu usage is actually good and that we are using the CPU Capacity. Am I right? I still do not know what causing the CPU Usage as the memory is okay and the page space used is very low so there is no memory swapping going on. There is also no i/O activities during the CPU surge.  Is there any good online document or link that we give me more insight on this cpu usage. I found a lot on the net but so far I have not found a single one to match what I am looking for.

Any advice and guidance would be greatly appreciated.

Thank you.
0
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 2000 total points
ID: 26076558
Hi,

all this doesn't sound really threatening. Your CPU usage values are just perfect - where are the 40% you mentioned in your comment?
Did you try topas to analyze which processes are actually consuming the CPU?
Or use nmon, whose output is a bit more meaningful.

Maybe it's just the frequency of the calls to your script being responsible for some CPU consumption?
You could check this frequency by counting the lines of your outputfile in regular intervals, like
while true; do wc -l /home/logs/systemlog.log ; sleep 30 ; done

If you don't have nmon already, it's here: http://www.ibm.com/developerworks/aix/library/au-analyze_aix/
Download: http://www-941.haw.ibm.com/collaboration/wiki/display/WikiPtype/nmon

I'm not aware of a single document to fit accurately to your problem.

developerworks in general is a good resource: http://www.ibm.com/developerworks/aix/

and here is a thing that could give you some hints:
http://www.ibm.com/developerworks/aix/library/au-aixoptimization/index.html?ca=drs-

This is an AIX tuning overview (it's for AIX 6.1, but most things are valid for AIX 5, too):
http://www.ibm.com/developerworks/aix/library/au-aix6tuning/index.html?S_TACT=105AGX20&S_CMP=EDU

Please let me know what you achieved, I'll assist you further, if needed.

wmp
0
 

Author Closing Comment

by:tommym121
ID: 31667148
Thank you for your help.
0
 

Author Comment

by:tommym121
ID: 26083951
Thank you for your help.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question