linux - Application on OSX cannot spawn more than 2048 threads -
i have rust application on on osx firing large amount of threads can seen in code below, however, after looking @ how many max threads version of osx allowed create via sysctl kern.num_taskthreads
command, can see kern.num_taskthreads: 2048
explains why can't spin on 2048 threads.
how go getting past hard limit?
let threads = 300000; let requests = 1; _x in 0..threads { println!("{}", _x); let request_clone = request.clone(); let handle = thread::spawn(move || { _y in 0..requests { request_clone.lock().unwrap().push((request::request::new(request::request::create_request()))); } }); child_threads.push(handle); }
before starting, i'd encourage read c10k problem. when scale, there's lot more things need keep in mind.
that being said, i'd suggest looking @ mio...
a lightweight io library rust focus on adding little overhead possible on os abstractions.
specifically, mio provides event loop, allows handle large number of connections without spawning threads. unfortunately, don't know of http library supports mio. create 1 , hero rust community!
Comments
Post a Comment