| |||||||||||
| |||||||||||
Parallel processing in PHP
PHP is designed - where necessary to the exclusion of other uses - as a web page tool. In other words, where a language design decision needs to made between something that is good for the web use, but bad for more general use, the decision will always be in favour of the web. "I don't care how it effects the other users" said Rasmus Lerdorf when I attended a lecture of his a year or two back - but what Rasmus (the PHP originator and mentor) means is that he really does care that it should be great for web users.
So ... most of the other language I teach had a "fork" function or equivalent from the early days which lets you split the process in two, with each half performing a different task. In PHP, it's there too - as from 4.1 - under the name pcntl_fork. But forking a complete process can be resource-heavy and tricky to code and there are other options too - such as setting off parallel actions on pipes. Here's some sample code links. Pinging multiple hosts in parallel Grabbing titles from multiple pages in parallel You can try the second example here if you wish. You'll notice that I've used the full path to PHP and my test script in the title grabber. That's because the PHP script will be called up with goodness only knows what path and current directory, and it's sometimes needed to get the thing to work. You may also find that some of the php.ini settings hamper you. Finally, a note of caution. If you write a script that goes out and grabs lots of information from other servers, you're writing an automata or robotic process and you should check that this is acceptable to your target site - their robots.txt file. (written 2007-01-03 17:40:03) Associated topics are indexed under H999 - Additional PHP MaterialH308 - PHP - Searches, and search engines W603 - Web and Intranet - Server Side Technologies
Some other Articles
Web site - a refresh to improve navigationFinding public writeable things on your linux file system No courses. No hotel guests. Rushed off our feet! PHP - static declaration Parallel processing in PHP span and div tags - a css comparison Open Source Courses and Business Hotel - products and prices for 2007 css - handling white space and pre Modernising from tables to cascading style sheets Search engine placement - long term strategy and success 1636 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33 at 50 posts per pageThis is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price. Link to Ezine home page (for reading). Link to Blogging home page (to add comments). |
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 707126 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho | |||||||||||