Sponsored Content
Top Forums UNIX for Advanced & Expert Users Writing a REST server to run on FreeBSD -- how to structure for concurrency? Post 302981733 by LittleCookieMon on Sunday 18th of September 2016 06:25:37 PM
Old 09-18-2016
Corona688 -- an additional question for you:

As to your advice on "My approach would be to have one thread which loops on accept() and puts the socket in a queue of some sort, for one of a fixed number of worker threads to grab it from and add it to the pile of sockets each worker thread is communicating with."

Is there a recommended queue or messaging feature to accomplish this that I should research?

I see quite literally there are message queues (system V?), and the use of msgget() msgsnd() and msgrcv(). Is this particularly what you had in mind, and if so, is there any things to be mindful of to send socket descriptors through a message queue?

Thanks again!

---------- Post updated at 06:25 PM ---------- Previous update was at 04:42 PM ----------

Corona668 / others:

Is this a reasonable way?

Parent process starts worker processes
Listens on a socket for incoming connections and accept()s them

On accepting new connection:

Using UNIX Domain socket, using SCM_RIGHTS send descriptor to child worker process that is running. Worker process is decided by simple counter, e.g. i++ that resets once i == #worker processes. Very basic round-robin approach.

Would this suffice over the message queue approach?

Last edited by LittleCookieMon; 09-18-2016 at 07:36 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

I'm looking for a 64-bit Desktop that will run Windows, Linspire, FreeBSD and Solaris

Ok, I've been shopping around and I've seen some nice one's, but they are either too expensive or they are not 64-bit; I want to be prepared for the future at the right price (under $3,000 with a decent configuration)! :D Where can I find a good 64-bit desktop or workstation that will run the... (0 Replies)
Discussion started by: Mr. Nice Guy
0 Replies

2. Shell Programming and Scripting

Shell script for a writing the directory structure to a file

Hi All, I am new user of shell scripting has come up with a problem. that I have a directory structure like : Home | |--------A | |----trunk | |-------A_0_1/ | | | |-------A_0_2/ | |--------B | ... (6 Replies)
Discussion started by: bhaskar_m
6 Replies

3. Shell Programming and Scripting

Script to run a command on all txt files present in a dir structure

Hi, I have a directory structure like the one given below root\a\b1 root\a\b2 root\b\b1 root\b\b2 . . . root\j\b1 root\j\b2 Now, there are a txt files in each dir and subdir, there is a root.txt I have to write a script where in i have to run a command called "genrb <filename>"... (6 Replies)
Discussion started by: vikramsinghnegi
6 Replies

4. UNIX for Advanced & Expert Users

Has anyone run the linux boinc client on FreeBSD

The reason I ask is because the einstein client in the freash ports is not the current one with boinc. No new work is being assigned. They sugested or asked if I could run boinc 6.10.17 linux in emulation and if so, I would be able to crunch einstein data. so, anyone done the linux emulation of... (0 Replies)
Discussion started by: droolin
0 Replies

5. Shell Programming and Scripting

Run SED for all index.jsp files across a directory structure.

Hi, I am a novice and require help once again. I have a over 200 file all called index.jsp placed in different directories The following Sed command gives me the data of all included jsp files in index.jsp sed -n -e 's/^.*page="\(*\).*$/\1/p' index.jsp How can I run the above... (6 Replies)
Discussion started by: rajkdutta
6 Replies

6. Shell Programming and Scripting

Need to copy a directory structure from one server to another

Hello All, I have got a dev server and a production server will call it as D server and P server. I have a dir structure in my D server and i need to create the same dir structure in P server also using a shell script. If i do a find . in my D server, i am getting an o/p like :- . ./vio... (9 Replies)
Discussion started by: Renjesh
9 Replies

7. UNIX for Dummies Questions & Answers

copying the dir/subdir structure from one server to another?

Hi All, I want to copy the dir/subdir structure from SERVER-A to SERVER-B without copying all the files in each dir. Is it possible using SCP / SFTP command? For example, SERVER-A has following two dir/subdirectories and files under each subdir. ... (1 Reply)
Discussion started by: Hangman2
1 Replies

8. Shell Programming and Scripting

Run command without over-writing

I have a script called script.sh that has the following in it. cat /home/auto/script.sh #!/bin/bash ARGA=$1 if ; then echo "${ARGA}:Confirmed" else echo "${ARGA}:Unconfirmed" fi I need a way to run this script, and then, after script has confirmed the... (9 Replies)
Discussion started by: SkySmart
9 Replies

9. Shell Programming and Scripting

Help with writing a script to run java commands in sequence in UNIX

Hi, Brand new to these forums, and I hope that someone can help me out. I'm trying to run the following command in UNIX java -jar GenomeAnalysisTK.jar -T SplitSamFile -dt NONE -R reference.fa -I my.bam --outputRoot /my/path/SampleFiles/Sample_ It executes the SplitSamFile from GATK, but I... (3 Replies)
Discussion started by: Wixaros
3 Replies

10. Shell Programming and Scripting

Run rest of script after parallel steps have completed

Hello gurus, I produce a number of .loc files in parallel depending on number of .csv in the folder for file in *csv do ./process.sh $file > $file.loc & done then I want to compile all the output from the previous step into a single masterlocfile and then perform the rest of the steps... (2 Replies)
Discussion started by: senhia83
2 Replies
GEARMAND(1p)						User Contributed Perl Documentation					      GEARMAND(1p)

NAME
gearmand - Gearman client/worker connector. SYNOPSIS
gearmand --daemon DESCRIPTION
This is the main executable for Gearman::Server. It provides command-line configuration of port numbers, pidfiles, and daemonization. OPTIONS
--daemonize / -d Make the daemon run in the background (good for init.d scripts, bad for running under daemontools/supervise). --port=7003 / -p 7003 Set the port number, defaults to 7003. --pidfile=/some/dir/gearmand.pid Write a pidfile when starting up --debug=1 Enable debugging (currently the only debug output is when a client or worker connects). --accept=10 Number of new connections to accept each time we see a listening socket ready. This doesn't usually need to be tuned by anyone, however in dire circumstances you may need to do it quickly. --wakeup=3 Number of workers to wake up per job inserted into the queue. Zero(0) is a perfectly acceptable answer, and can be used if you don't care much about job latency. This would bank on the base idea of a worker checking in with the server every so often. Negative One (-1) indicates that all sleeping workers should be woken up. All other negative numbers will cause the server to throw exception and not start. --wakeup-delay= Time interval before waking up more workers (the value specified by --wakeup) when jobs are still in the queue. Zero(0) means go as fast as possible, but not all at the same time. Similar to -1 on --wakeup, but is more cooperative in gearmand's multitasking model. Negative One (-1) means that this event won't happe, so only the initial workers will be woken up to handle jobs in the queue. COPYRIGHT
Copyright 2005-2007, Danga Interactive You are granted a license to use it under the same terms as Perl itself. WARRANTY
This is free software. IT COMES WITHOUT WARRANTY OF ANY KIND. AUTHORS
Brad Fitzpatrick <brad@danga.com> Brad Whitaker <whitaker@danga.com> SEE ALSO
Gearman::Server Gearman::Client Gearman::Worker Gearman::Client::Async perl v5.10.1 2009-10-05 GEARMAND(1p)
All times are GMT -4. The time now is 06:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy