I know that you can build multi-threaded Clojure program explicitly using the tools in java.util.concurrent.Executors and language constructs like agents and atoms. However, if I write a Ring app, how will a multi-threaded server (like Jetty or Immutant) change the way it runs? If I do some initialization (e.g. loading configuration, setting up a database connection pool) before I start serving requests, will I end up with duplicated, possibly inconsistent work in different threads? Will each request be handled by one thread?
How does a multi-threaded web server affect a Clojure program?
293 Views Asked by Nat Knight At
1
There are 1 best solutions below
Related Questions in JAVA
- Add image to JCheckBoxMenuItem
- How to access invisible Unordered List element with Selenium WebDriver using Java
- Inheritance in Java, apparent type vs actual type
- Java catch the ball Game
- Access objects variable & method by name
- GridBagLayout is displaying JTextField and JTextArea as short, vertical lines
- Perform a task each interval
- Compound classes stored in an array are not accessible in selenium java
- How to avoid concurrent access to a resource?
- Why does processing goes slower on implementing try catch block in java?
- Redirect inside java interceptor
- Push toolbar content below statusbar
- Animation in Java on top of JPanel
- JPA - How to query with a LIKE operator in combination with an AttributeConverter
- Java Assign a Value to an array cell
Related Questions in MULTITHREADING
- new thread blocks main thread
- WPF MessageBox Cancel checkbox check
- How to avoid concurrent access to a resource?
- run oncomplete event in async
- Threading Segfault when reading members
- Function timeouts in C and thread
- How are multiple requests to Task.Run handled from a resource management standpoint?
- Acumatica perfomance with threads
- Wait and Notify in Java threads for a given interval
- Different behavior of async with Visual Studio 2013(Windows8.1) and GCC 4.9(Ubuntu14.10)
- How to return blocking queue to the right object?
- background thread using Task.Run
- deletion and cleanup of worker thread in Qt crashes
- Pipeline-like operation using TChan
- implementing in app purchase on android
Related Questions in CLOJURE
- core.logic CLP(FD) with ClojureScript
- clojure worker-only app on heroku fails with Error R10
- How do persistent data structures help make Om faster
- Union in HoneySQL
- Reduce memory consumption in development
- twitter response: "error 32: Could not authenticate you" from Heroku, but not desktop
- How can I create a global object, and attach a string and a function to that object, in ClojureScript?
- AngularJS $http GET method to backend server: Request Method:OPTIONS 405
- Clojure : event listener on domina library
- Why is my streamparse topology definition complaining about a wrong number of arguments to thrift$mk-topology?
- Clojure defn name as multiplier
- clojure quoting inside let
- Build macro result with loops
- How do I unit test clojure.core.async go macros?
- Datomic and HornetQException "unable to validate user"
Related Questions in IMMUTANT
- Create new HTTP call from Ring Request
- How to use config immutant to implement quartz cluster?
- immutant failing to add a cache to a web cache container
- How do I configure HornetQ for STOMP in Immutant 2
- error while using immutant server to access page from browser
- Immutant2 server logs showing fishy error message
- how can lein midje :autotest be made to work with immutant?
- Can Immutant be configured to use something other than 8080 as well as to use SSL?
- how can immutant be configured to serve ips other than localhost (127.0.0.1)
- Preferred way to connect to Immutant Message Queuing service from eg C# application
- clustered immutant2 instances
- How to start immutant message queue?
- Getting a clojure map with keywords from a POST using Liberator
- Sending an HTTP request while running Immutant
- Clojure Immutant 2 server Undertow; how to handle http POST?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Your Clojure code will lie dormant w/o any thread until a web request arrives (essentially you are writing a library/subroutine, not a main program). Jetty et al will assign a thread to invoke your Clojure code, supplying the relevant parameters. If you make any DB requests, they typically go out over a socket to the DB machine, which will assign a thread to handle your request and return the relevant results. Your thread in Jetty will receive the data from the DB and continue processing from there.
The important part is that each piece of information is a treated like an immutable message. The message can be copied and passed from one system to another without losing its meaning. It doesn't matter how many copies are made and deleted, only that one copy gets to the final destination.
A simple webapp typically doesn't need to do any multithreading of it's own, since the thread handling & synchronization provided by Jetty and the DB are usually all that is needed. If you do your own multithreading for something, you mostly just need to worry about your own internal synchronization.
You can see some good information online at The Clojure Cookbook.
I can also highly recommend the book Web Development with Clojure.