The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. February 12, 2012, 04:45:08 PM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: Any idea about a Multitasking alternative to Gearman?  (Read 810 times)
netmktg
Rookie
**
Offline Offline

Posts: 37



View Profile
« on: August 20, 2010, 06:53:25 AM »

A long while back I had a discussion on this board about writing a mysql-based multitasking system. And it has been holding out well so far  Nerd

In my existing system, the Client server "pops" the job of the mysql Task queue and executes it but it REQUIRES all the function definitions. That means the entire code has to be duplicated & updated on each client server.

I wanted to move over to something more independent/stateless. I thought Gearman was the solution, but its not... each Gearman Worker App also requires all the functions to be defined on the worker-side.


It does seem a rather far fetched idea in terms of PHP ... but is there something out there already that can also "pickup" the compiled function definitions from the job server and execute on the client server. That would mean the client server would need just a couple of lines to pop a job, no other files should be required.
Logged
perkiset
Olde World Hacker
Administrator
Lifer
*****
Online Online

Posts: 9792



View Profile
« Reply #1 on: August 20, 2010, 09:28:47 AM »

If the dispatching server also popped code that was eval'd and run on the fly, then you'd not need the code locally, but then you're essentially sending your entire app with every job.

I don't know of any simple way for a local app to call remote functions in php, if I understand your request correctly.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
intel352
n00b
*
Offline Offline

Posts: 1


View Profile
« Reply #2 on: October 20, 2010, 05:54:17 PM »

Why not remote file inclusion (via HTTP), or inclusion of code from a central shared drive?
Assuming your workers are on a private network, either method could work fine.

If you are not on a private network, then you would need to go to extra lengths to ensure that HTTP inclusion is secure.

Read more about HTTP inclusion here: http://php.net/manual/en/function.include.php
Logged
lamontagne
Journeyman
***
Offline Offline

Posts: 89


View Profile
« Reply #3 on: October 21, 2010, 09:05:42 AM »

Cant you just do this with git and write a batch file to push to remote nodes after changes are made?

Honestly i can think of a few ways to do it and each has a different benefit. I'll list a few:

GIT - You're going to be pushing the files containing functions onto the client machines. This still requires duplication but will be much easier to maintain and make changes with. Bulky on file storage space but each nodes code can be individualized down to the most granular detail.

SOAP/REST API - A call is made to a function on a remote machine sending the parameters in an XML/REST format. This works best if a central server needs to dispatch jobs to multiple spiders. Network load increases

Remote File Include (what intel352 is talking about) - If the script is long running after it is fired up (loops forever reading from db) this is your best bet but provide a central way to kill the app on all machines (basically check if file exists on each loop, when you need to kill all clients delete the file , or create individual file for each node using a unique id, if file does not exist the loop simply does a sleep(30)... so it will check if file exists again every 30 seconds.. upon restart re-include central functions).. basically you build it to sit idle if you want it to. The file you remote include will be stored in memory on the server but not on disk.
« Last Edit: October 21, 2010, 09:22:17 AM by lamontagne » Logged

"Long time no see. I only pray the caliber of your questions has improved." - Kevin Smith
netmktg
Rookie
**
Offline Offline

Posts: 37



View Profile
« Reply #4 on: October 21, 2010, 10:50:33 PM »

Why not remote file inclusion (via HTTP), or inclusion of code from a central shared drive?
Assuming your workers are on a private network, either method could work fine.

Can't sleep with the devil... the files are not kept publicly accessible.

Yep, revision control is meant for code updation. But my code still is open for all to see.
Maybe I just need a Php compiler. My original line of thought was to avoid floating my entire codebase around on multiple vps servers.

I am already using a custom mysql-based Task system which bundles parameters. The execution can be disabled for all Clients in the central database itself by changing a "Flag".
Logged
lamontagne
Journeyman
***
Offline Offline

Posts: 89


View Profile
« Reply #5 on: October 22, 2010, 09:01:23 AM »

Oh... well if you need to keep the code private on the clients yet distribute it you're going to have to compile/encrypt in some way and with php it's never going to be 100% as someone will always be able to nullify the script or decompile... if you can somehow use a REST/SOAP api and put the confidential parts of those functions on the central server (as other functions) and simply pass back the results that would work, but of course you'll have a network load and the design may end up very awkward... At the end of the day php will read it as php so leaving it as php will always be reversible... I suppose you could create a php extension (dll) and simply distribute that and use it in the php code (http://www.php.net/manual/en/function.dl.php) but even then others would just have to implement the dll as well, unless you include a few routines to phone home and do some checks (send remote ip and remote os and whatnot)... never built a php extension but it seems plausible...


Yeah, come to think of it a php extension that phones home would be your best bet....
« Last Edit: October 22, 2010, 09:06:00 AM by lamontagne » Logged

"Long time no see. I only pray the caliber of your questions has improved." - Kevin Smith
perkiset
Olde World Hacker
Administrator
Lifer
*****
Online Online

Posts: 9792



View Profile
« Reply #6 on: October 22, 2010, 09:51:40 AM »

The only issue with the php extension is that you need to put it into the php.ini and restart Apache for it to take effect. I've written a few and they ROCK - i nfact, this is my standard trick when PHP just doesn't have the juice to do (something) really fast. No worries for someone like me, but if you are to sell it to people that are using normal hosting, then getting the hosting company to install a custom php extension might prove ... difficult. In fact, unless you really know the details of the target machine and can precompile it then you'd want to distribute the source and let it get built on the destination machine ... which eliminates the advantage of compiled obfuscation entirely.   
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!