LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-24-2013, 11:29 AM   #1
sniff
Member
 
Registered: Jan 2003
Location: Durham UK
Distribution: openSUSE/Debian/ubuntu
Posts: 362

Rep: Reputation: 42
Question MySQL Concurrent Updates


Hello,

I have a database question and would value some input from more experienced MySQL users;

I have two programs (one of which I would like to run on more than one computer). The model is a producer and then 1+ workers. All programs written in Java.

The producer downloads some information and stores it in a database. This happens at unpredictable times.

The workers process the new data in the database, before changing it slightly (including setting a flag that says that data was successfully processed). Currently the 1 worker just works in a loop. It does a select and gets all the unprocessed data. Processes it and then does another select to see if new data has arrived. If not it waits for a while before trying again.

So, the processing takes a while. about 2mins per data point there are about 11000 data points and its going up. So we need more horsepower....

If I run more than 1 worker on more than 1 computer then I have a problem that I need help with. Worker 1 does select gets list of unprocessed data. Worker 2 does the same gets a similar list, they end up processing the same data some of the time. FAIL. Is there an SQL solution to this problem? Only request one data point at a time and somehow flag the row? Seems rubbish. Or should I make another program that gives tasks out to the workers... sort of a man in the middle?

I am guessing that this sort of access problem is solved pretty well for databases?

I have written distributed systems before but not ones that use a MySQL table to store the data and results and has computers putting in new data that are not even on the same network....

Cheers,
Phil
 
Old 04-25-2013, 06:48 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,356

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Yeah, I'd go master process and 'N' worker processes/threads.
The Master scans for new rows and hands off sets of them eg sets of 10, to each worker.
Obviously each row would need a unique identifier, if necessary set by the Master.
The Master just hands out the 10 unique ids to each worker. This would be a natural problem to solve with threads. as the Master would want to know when each worker is ready for the next set.
 
Old 04-25-2013, 07:06 AM   #3
sniff
Member
 
Registered: Jan 2003
Location: Durham UK
Distribution: openSUSE/Debian/ubuntu
Posts: 362

Original Poster
Rep: Reputation: 42
Thanks, I will do it that way. That's basically how I do things normally using Java Remote MPI. I will build a producer that hands out the work and checks it back in again.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
MySQL Updates With Null When Perl Script Run From Shell Script ThisGuyIKnow Programming 6 08-12-2008 09:56 AM
Updates broke mySQL?? jasonj75 Ubuntu 1 05-20-2006 03:16 PM
Concurrent installation of mySQL & postgreSQL theNbomr Linux - Software 1 02-27-2006 02:31 PM
Apache2, MySQL and PHP broken after updates mazzo Linux - Networking 10 09-15-2005 07:12 AM
Does redhat (fedora 2) ever offer updates of mysql caperneoignis Linux - Software 1 08-10-2004 01:16 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:22 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration