Comments (15)
http://michael.otacoo.com/postgresql-2/postgres-9-5-feature-highlight-skip-locked-row-level/ might be interesting to talk about.
Tanga.com's been using que since March this year without any issues, we've processed around 100 million jobs. We love how the jobs are transactional with our other data -- if the data gets saved, the related jobs are also saved. We also love being able to manage the job queue via SQL.
Biggest con so far was no web-ui for monitoring jobs, but I think that's been solved by the project in the README, haven't looked at it yet.
from que.
Thanks, Joe!
from que.
I'm just now looking at Que to replace sidekiq because I can create most my jobs using INSERT SELECT semantics and save having to iterate 1 million rows in ruby and invoking a single job at a time.
One thing I'm curious is why you do not use stored procedures instead of sql for high-frequency statements? Would you be interested in a pull request? Versioning can be handled via comments on the sproc or md5 of the function contents.
from que.
Que uses prepared statements, should be just as fast as stored procedures (right?).
from que.
@joevandyk Yes if it does, there is a case statement at https://github.com/chanks/que/blob/f677acf34683a281c0915757e2f9566a07c903ad/lib/que/adapters/base.rb#L41 so cursory glance says its not guaranteed. Also not sure if it respects prepared_statements: false
ActiveRecord configuration setting. We are planning to use pgpool to multiplex connections as we add nodes, requiring no prepared statements.
Also, using stored procs enables a pure sql api to be used from within postgres.
from que.
Prepared statements are used for all common queries unless the connection is currently in a transaction. This was done because ActiveRecord connection failures would occasionally result in the same connection objects referring to different backends, so a statement that was thought to be prepared wouldn't be and an error would be thrown. This is fine outside of a transaction, since we can just prepare it and retry, but inside a transaction the error would force a rollback, which would be unpleasant for the user. So, inside a transaction, plain non-prepared SQL is always used for safety. This isn't a huge concern, because the only significantly complex statement (the job lock query) is never executed inside a transaction.
Que doesn't respect ActiveRecord's configuration settings, because it only interacts with ActiveRecord the bare minimum that it needs to in order to access its pool of PG connection objects. It seems like the usage of prepared statements would be a problem for remote connection pools like pg_bouncer (or pgpool, I'm guessing), but nobody's lodged a complaint, so perhaps it isn't an issue for some reason I'm unaware of? If you run into problems I'd be happy to add a configuration option for disallowing prepared statements.
The prospect of using functions instead of prepared statements is interesting, but I think I'd only be convinced to move Que in that direction if there were evidence that they're significantly faster than prepared statements (prepared statements with a local connection pool being the way to go for the vast majority of apps), so much so that it'd be worth the added complexity of potentially migrating them between versions.
from que.
Pros:
- Extremely easy to set up. Makes us more likely to use background workers.
- Few external dependencies (no Redis).
- Very lightweight.
- Works in development just as well as production.
- Runs great on a single Heroku web dyno without requiring a worker dyno.
Cons:
- Dumb/confusing name. Seriously, at my shop we use Que every time but complain about the name every time.
- Requires a relatively recent PostgresQL, which some Rails hosts don't support (looking at you, WebFaction).
- Can't use
rake db:load:schema
.
from que.
Que uses prepared statements, should be just as fast as stored procedures (right?).
Stored procedures excel at reducing round-trips to the database, which can provide substantial improvements in a number of applications. I think in practice, in Que's case this could be an improvement since the algorithm for grabbing an item does at least two round-trips for every item, but even four or six (!) wouldn't be out of the question on a high concurrency queue.
However, they come at a price as well, since you need to handle updates to them, integrate them into your source control management etc.
from que.
I may be wrong, but my understanding is that in PG, the same MVCC snapshot is held throughout the entire execution of the function, so it wouldn't help us with the race condition that necessitates the second query to make sure the job still exists.
from que.
I may be wrong, but my understanding is that in PG, the same MVCC snapshot is held throughout the entire execution of the function, so it wouldn't help us with the race condition that necessitates the second query to make sure the job still exists.
Not in READ COMMITTED (which is the default) mode for VOLATILE functions.
from que.
Ah! Interesting. I'll have to play with that at some point, thanks!
from que.
This should probably be in a different thread, but I implemented something similar just now; I'm running the tests as we speak to see what happens.
from que.
We switched from Sidekiq to Que.
Where Que Rocks
- Cutting out the redis dependency eased setting up both development and production environments. If you've dealt with the pain of using Redis over SSL, you understand.
- Being able to queue in the same transaction as a web request is a killer feature. Transaction success + failed to enqueue or transaction failed + enqueue success were two occasional oddities we had with Redis.
- Runs plenty fast for our use case.
Where Que lacks
- Hooks. Having access to a middleware style pipeline for extensions like transaction wrappers and error reporting would be helpful.
- Stats. There's no historical statistic information. Being able to see jobs/sec, slow jobs, and 24 hour count would help give insight to the state of Que.
- Full fledged web interface (I'm working on that
😉 ).
Overall the experience has been positive. I dig the project and intend on continuing to use it.
from que.
Thanks, everyone. One last request, as I'm putting together my presentation for tomorrow - would people be willing/able to share the names of sites where they're using Que in production? And if you want to include the number of jobs you've put through it, that'd be cool, too, but don't feel obligated. I'd like to be able to show some concrete evidence that Que is serious business :)
And if you want to include a one-line description of what your site does, I'll be happy to include it. Free publicity and all. :)
from que.
Didn't get anyone in time for my talk, but it was alright, I asked kind of late. Thanks for your input everyone - I think it was recorded, so if it's posted somewhere I'll link to it in the README.
from que.
Related Issues (20)
- Need support for draining queues HOT 3
- Support JRuby
- best way to re-activate a job HOT 2
- Que::ActiveRecord::Model.by_args incompatible with ActiveJob JobWrapper HOT 1
- Flaky Errors HOT 2
- Proper way of removing Que from project? HOT 3
- Schema version comment doesn't end up in Rails structure.sql HOT 3
- Que v1 should state that it's incompatible with ruby 3 HOT 2
- Tests fail in Docker on Apple Silicon
- Timeline for v2.0.0. release HOT 1
- Remove unnecessary trigger that notifies about job state transitions HOT 2
- Deprecated method used in connection.rb HOT 1
- Check that all que migrations have been applied at startup HOT 1
- Detect Que schema version missing due to bug in Rails schema dump - affects all versions of Rails 7 prior to 7.0.3
- Migration to v. 2.2.0 failed HOT 2
- Stats about failing jobs HOT 2
- upgrading from v0 to v2 when already on ruby 3 HOT 5
- Migrating from 1.0.0.beta4 to 1.4.1 HOT 5
- Que fails to calculate args and kwargs on Ruby 3.2 with ActiveJob HOT 1
- Migration fails when adding Que to a new project (with rspec) HOT 8
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 que.