I think most of this has already been said, but let me give you my spin and some real-world examples.

A CGI Script: Apache calling your script which accesses a MySQL database will take care of most of your problems for you as far as SMP goes. Since most CGIs are pretty short and simple scripts, you wouldn't see much, if any, speed increase with more than one CPU (from the scripts standpoint).

Stand-Alone Scripts: Say you had a script that parses text files, just for fun, let's say they are a couple hundred megs worth. Then let's say that you wanted to parse those files and insert info about them into a database. Here is where you could use a threaded program. Have one thread parsing the text files, and another thread writing to the database. Running on a multi-CPU system would help you some in this case, but to parse a text file and write to a database, your bottleneck isn't going to be the CPU in most cases, but your disk, or your network if writing to a remote database.

CPU Intesive Apps: Say the several hundred meg files had had above are filled with users connection information, like timestamps, and your boss wanted to know the max number of users on at any given point with a 1 minute granularity. All you have is connection info so you are going to have to walk through those several hundred megs and compare them all. Massively CPU intensive. In this case, you would benefit GREATLY from threads and a multi-CPU host.

So in summary: Multiple CPUs are obviously only going to help you when your bottleneck is the CPU. In most cases on a modern server, it is your disk, or your network.


In reply to Re: Perl and mutli processors by erasei
in thread Perl and mutli processors by Sihal

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.