Comments (5)
other features like our "memory limiter" could be developed on the same set of rails without us having to fork or monkey patch the code base.
Have you seen: #92
I'm not convinced a plugin system is needed for that, but also perhaps I don't quite understand what you have in mind?
Also the soft timeout is a bit inadequate right now, I need to make some changes to it.
from pitchfork.
Yes we're aware of after_request_complete
but just as with the timeout implementation it wouldn't work because we wanted to kill a worker during the request if it went above a certain threshold, as you have with the timeout thread.
Maybe you can add like a around_request
event which we can yield to perform the request and spawn a thread that monitors the memory usage while the request is running and kills it (like timeout does) if it goes above a threshold.
Does that make sense?
EDIT: Meant to say around_request
🤦 not after_request
from pitchfork.
we wanted to kill a worker during the request if it went above a certain threshold,
I don't understand why you'd want to do that. But if you really want to do that, you don't need anything special from Pitchfork, you can just spawn that thread from after_worker_fork
. So I don't see any need for a plugin system here.
from pitchfork.
Sorry @casperisfine not sure how after_worker_fork
helps.
request_env = process_client(client, worker, prepare_timeout(worker))
@after_request_complete&.call(self, worker, request_env)
worker.increment_requests_count
What we need is a callback before process_client is called that allows us to begin the memory thread monitor, just as you're doing with timeout via prepare_timeout(worker)
Maybe something simple like before_request
like:
@before_request&.call(self, worker)
request_env = process_client(client, worker, prepare_timeout(worker))
@after_request_complete&.call(self, worker, request_env)
worker.increment_requests_count
Will you accept a PR for this?
from pitchfork.
My point is you don't need to start that memory monitor thread on each request. Actually it would be really bad for performance.
You can just do something like:
after_worker_fork do
loop do
if memory_exhausted?
exit! 42
end
sleep 1
end
end
But again, I don't see why you wouldn't just do that on after_request_complete
so you let the request terminate first.
from pitchfork.
Related Issues (20)
- Bug: manual reforking doesn't check `fork_safe?`
- Explore: fairer load balancing HOT 2
- Sequel PG::ConnectionBad on refork. HOT 9
- Any way to make timeout do a sigterm or sigquit before sigkill? HOT 2
- Improve resiliency to process corruption HOT 1
- Weird behaviour reforking with Rails I18n translations HOT 3
- Support Ruby 3.3's `Process.warmup` before fork HOT 2
- question: Is it safe to use with unicorn-worker-killer? HOT 6
- feature request: make after_worker_fork to be called after forking mold HOT 6
- Improve `rack.after_reply`
- (maybe bug?) undefined method `close_write' for nil:NilClass (NoMethodError) HOT 4
- worker crashes (and dump backtrace) after fork HOT 9
- Unicorn migration guide HOT 1
- Explore: Task scheduling API HOT 5
- Fatal interaction with the `request_store` gem and `RACK_ENV` HOT 12
- Usage of the `logger` gem HOT 1
- Test failure against Rack 3.1 HOT 5
- `rack.hijack` results in `EOFError` when the response doesn't incude `content-length`
- Access to listener_names within before_service_worker_ready HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pitchfork.