Link to home
Start Free TrialLog in
Avatar of tommym121
tommym121Flag for Canada

asked on

Reduce CPU time on AIX system

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
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

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
 
Avatar of tommym121

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you for your help.
Thank you for your help.