LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-10-2006, 02:57 PM   #1
adi22pal
LQ Newbie
 
Registered: May 2006
Posts: 5

Rep: Reputation: 0
Multiple writer Single reader


Hi

I have multiple processes (writer) running on a linux machine (processes are written in perl, c++, php5 and java) which generate messages

I have one process (reader) (can write in any language depending on choice) which takes a message and transfer to a remote server.

Aim is that writer will write messages which reader must read on a near realtime basis (atmax a minute delay). What approach should i choose for this kind of job.

I am thinking of file based mechanism where each writer write to same file and reader reads the file after a minute keeping track of file size and max data to read in a minute slot. But this has problems like

1. How do i achieve multiple process appending to same file without data loss and without performance impact on writer

2. Performance impact of file writing.

Please suggest me alternate / best approach.

PS: Choice of linux distro should not matter
 
Old 10-10-2006, 04:32 PM   #2
cavalier
Member
 
Registered: Feb 2005
Location: Denver, CO
Distribution: Slack 12, tweaked just so (though I'm also a fan of Ubuntu)
Posts: 198
Blog Entries: 1

Rep: Reputation: 30
My first instinct would be to use multiple files, and have the reader poll them each in turn, looking for a timestamp to keep the operations in order. That gets away from corrupting a single file with mulitple writers.
 
Old 10-10-2006, 04:54 PM   #3
adi22pal
LQ Newbie
 
Registered: May 2006
Posts: 5

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by cavalier
My first instinct would be to use multiple files, and have the reader poll them each in turn, looking for a timestamp to keep the operations in order. That gets away from corrupting a single file with mulitple writers.
Yes, I gave it a thought .. The approach i came up with multiple files is this

Each process writes to a file with name based on it's pid, ensuring mutual exclution amongst processes. But reading the files is little too complex in this case, because

1. Reader need to maintain ptr to all the open files.
2. Reader must continously poll for any new file created.
3. Reader must maintain multiple recovery log in case of system crash. Recovery log will contain position of reader in each file.

Apart from that .. How will read data will be erased from files ?
 
Old 10-10-2006, 06:13 PM   #4
cavalier
Member
 
Registered: Feb 2005
Location: Denver, CO
Distribution: Slack 12, tweaked just so (though I'm also a fan of Ubuntu)
Posts: 198
Blog Entries: 1

Rep: Reputation: 30
I'm back in front of my linux box now, and I thought about it some more. Given that you've got multiple writers, have you considered using pipes?

http://en.wikipedia.org/wiki/Named_pipe

that way you could have the data sit in the pipe until it's read by the reader at which point it's gone. No need for any sort of internal pointers, and if the reader goes offline, the pipe persists until it comes back up.
 
Old 10-10-2006, 07:05 PM   #5
adi22pal
LQ Newbie
 
Registered: May 2006
Posts: 5

Original Poster
Rep: Reputation: 0
Quote:
http://en.wikipedia.org/wiki/Named_pipe

that way you could have the data sit in the pipe until it's read by the reader at which point it's gone. No need for any sort of internal pointers, and if the reader goes offline, the pipe persists until it comes back up.
Writer can be in perl, php, java too ... is it easy to implement pipes for them too.
 
Old 10-10-2006, 07:28 PM   #6
cavalier
Member
 
Registered: Feb 2005
Location: Denver, CO
Distribution: Slack 12, tweaked just so (though I'm also a fan of Ubuntu)
Posts: 198
Blog Entries: 1

Rep: Reputation: 30
The only one I'm unsure of is php. I've seen it done in C, C++, Java and Perl, but never in php.
 
  


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
K3B reader/writer nrunge Linux - Software 1 11-17-2006 03:56 PM
problems with cd/dvd-writer/reader knaalto Linux - Hardware 4 04-11-2005 06:43 PM
oo writer single spaced? zippo85 Linux - Software 7 03-31-2005 07:41 PM
usb reader/writer stick jmdlcar Linux - Hardware 7 02-05-2004 09:30 PM
need help installing card-reader/writer arnethepenguin Linux - Hardware 3 06-23-2003 03:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:39 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