Unix Web Hosting for Developers

Unix - Unix Like Operating Systems

display still shows that I’m using that 100MB

Filed under: Guide To FreeBSD — webmaster @ 6:02 am

display still shows that I’m using that 100MB of swap, while I have over 200MB of memory free. Using swap space is not a bad thing, especially since a program will typically spend 80 percent of its time running 20 percent of its code. Since much of the rest of that time spent running is startup, shutdown, and error code, you can safely let those bits go to swap space and have minimal impact. So don’t worry if you find that you’re using a bit of swap space on occasion. But, if you’re constantly using swap, you probably need more memory. CPU Usage A processor can do only so many things a second, and if you want to do more than your CPU can handle, the requests will start to queue up. You’ll develop a processor backlog, and the system will slow down. That’s CPU usage in a nutshell. If top shows your CPU hovering around 100 percent all the time, you must take action. While new hardware is certainly an option, you do have other choices. For one, investigate the processes running on your system to see whether they’re all necessary. Did some junior administrator install the SETI@Home client (/usr/ports/astro/setiathome) to hunt for aliens with spare CPU cycles? Are there things running that were important at one time, but are now unnecessary? Find and kill those unnecessary processes and make sure that they won’t start the next time the system boots. Once that’s done, evaluate your system performance again. If you still have a problem, try rescheduling or reprioritizing. Rescheduling Rescheduling is easier than reprioritizing, and it is a relatively simple way to balance system processes so that they don’t load up on CPU time. As discussed in Chapter 9, you can use cron(1) to schedule system tasks for various times, but users can use it too. If you have users who are running massive compile jobs or doing huge database queries, you might consider using cron to schedule them to run at night. Frequently, jobs such as the monthly billing database search can be run between 6 PM and 6 AM, and nobody will care. Similarly, you could schedule your make buildworld && make buildkernel to start at 1 AM. Reprioritizing with Niceness If rescheduling won’t work, you’re left with reprioritizing, which is a bit trickier. When reprioritizing, you tell UNIX to change the importance of a given process. For example, if you want a software install to run, but only when nothing more important is running, you reprioritize it with “niceness,” which is simply a relative measure of how much CPU time a process demands. The nicer a process is, the less CPU time it demands. The default niceness is 0, but niceness runs from 20 (very nice) to -20 (not nice at all). (This might seem backwards; you could argue that a higher number should mean a higher priority. That leads to a language problem, though, as calling this factor “crankiness” or “greed” didn’t seem like a good idea at the time.)[4] In the top display seen earlier (in the “Using Top” section) you saw a PRI column for process priority. FreeBSD calculates a process priority by combining a variety of factors, including niceness, and runs high-priority processes first whenever possible. Niceness affects priority, but you cannot directly edit priority. 412

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost PHP Web Hosting services

1 Comment

  1. 2268fd04abcaac984246…

    2268fd04abca…

    Trackback by 2268fd04abcaac984246 — October 2, 2007 @ 8:44 am

RSS feed for comments on this post. TrackBack URI

Sorry, the comment form is closed at this time.

Powered by Unix Web Hosting