Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,634 members, 7,809,385 topics. Date: Friday, 26 April 2024 at 08:35 AM

Background Process In PHP - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Background Process In PHP (1889 Views)

My New C# Open Source App Prevents Laptop Background Data Consumption On Windows / Online Shopping System In Php Documentation Help / Running Python Codes In Php (2) (3) (4)

(1) (Reply) (Go Down)

Background Process In PHP by adewaleafolabi(m): 6:08pm On Dec 30, 2012
Nature:
1. I am on a windows shared host which implies there's a limit to the amount of CPU resources and program execution time.
2. System admins of these hosts are usually quite unforgiving about CPU resource limit boycotting and usually suspends offenders account without warning.
3. Location redirect is effectively limited to 10 redirects

Language: PHP

Problem: I have a large a large array of over 10,000 members. I need to send an email/SMS to each of these members at random times which i simply have no control over. Trying to do this from a php page would usually break or simply not complete.
I was able to achieve some progress by breaking this array into smaller units and sending incrementally and using php redirects and JavaScript windows.location to convince the browser that its not in an endless redirect loop.

I know there would be a more efficient way of doing things. Especially one that doesn't rely on the browser or user input. for instance if the user closes the page, the sending process wouldn't complete as i need the windows.location to run within a browser.

I could use cron and tell it to run throughout the day, but am not quite comfortable with the fact that cron is running every second in a day.

Need: I want something that acts like a daemon or service which would listen for when the messages would be sent and the user can leave or close the browser or navigate to another page and the process still runs in the background.

Thanks
Re: Background Process In PHP by Nobody: 7:47pm On Dec 31, 2012
Forking Processes in PHP is really trivial, Cron is your best bet, just make sure it is has interval of probably 30mins or 1 hour. besides forking processes on Windows not sure it will work. check your PHP Manual on PCNTL
Re: Background Process In PHP by adewaleafolabi(m): 9:17am On Jan 01, 2013
@pc_guru
Prcess forking won't work since its a windows host.
sure i've considered cron but due to the unpredictable nature of the times the messages would be sent as well as the near zero lagpolicy on messages delivery i'd be forced to make cron run every minute, which i find quite annoying.

I'd use cron and live with it for a while and change hosts later.
Thanks
Re: Background Process In PHP by lordZOUGA(m): 10:35am On Jan 01, 2013
or you can change hosts..
Re: Background Process In PHP by Nobody: 10:54am On Jan 01, 2013
Yeah i think we should discuss more on this, because handling issues like this with Large user base websites becomes a daily concern, but left to me i think its time to change to a better host, i would advise Siteground but basic-dedicated hosting you can see if it fits your needs. anyway let me know when you change host.
Re: Background Process In PHP by adewaleafolabi(m): 6:44pm On Jan 01, 2013
thanks, getting a dedicated host might just be the best option.

(1) (Reply)

Xamarin Is Now Free For Andriod And iOS App Developers / Am Too Old To Learn Programming ! / Challenge: Regex Content Generator

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 11
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.