Skip to content

Commit 3533276

Browse files
committed
Update README.md with connection_pool gem instruction and add benchmark results comparing Ruby 3.4.8 and Ruby 4.0.0 multithreaded
1 parent 6b2e2b5 commit 3533276

File tree

2 files changed

+38
-12
lines changed

2 files changed

+38
-12
lines changed

README.md

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,17 +189,30 @@ improve performance by executing multiple tasks concurrently. In
189189
this case, it makes multiple HTTP requests to an API endpoint using
190190
a thread pool of persistent connections.
191191

192+
Note: `gem install connection_pool` to run this example.
193+
192194
**Benefits:**
193195

194-
* Improved performance by avoiding the overhead of creating and
195-
destroying connections for each request.
196-
* Efficient use of resources by sharing connections among multiple
197-
threads.
198-
* Concurrency and parallelism, allowing multiple requests to be
199-
processed simultaneously.
196+
* Improved performance by avoiding the overhead of creating and destroying connections for each request.
197+
* Efficient use of resources by sharing connections among multiple threads.
198+
* Concurrency and parallelism, allowing multiple requests to be processed simultaneously.
199+
200+
benchmark: (demo/demo_thread_pool.rb)
201+
202+
** Benchmark Ruby 3.4.8 vs Ruby 4.0.0 **
200203

201204
benchmark: (demo/demo_thread_pool.rb)
202205

206+
| ruby | runtime (s) | thread | time/thread (s) |
207+
|------|------------:|-------:|----------------:|
208+
| 3.4.8 | 0.018644 | 4 | 0.004661 |
209+
| 4.0.0 | 0.017302 | 4 | 0.004326 |
210+
211+
Ruby 4.0.0 shows a slight improvement over Ruby 3.4.8, but the difference is not significant using thread.
212+
Ractor could be considered for a more efficient use of resources but it's still in the experimental stage.
213+
214+
Note: in this benchmark, `thread == HTTP connections`.
215+
203216
### Real world search without persistency
204217

205218
```ruby

README.md.erb

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,17 +209,30 @@ improve performance by executing multiple tasks concurrently. In
209209
this case, it makes multiple HTTP requests to an API endpoint using
210210
a thread pool of persistent connections.
211211

212+
Note: `gem install connection_pool` to run this example.
213+
212214
**Benefits:**
213215

214-
* Improved performance by avoiding the overhead of creating and
215-
destroying connections for each request.
216-
* Efficient use of resources by sharing connections among multiple
217-
threads.
218-
* Concurrency and parallelism, allowing multiple requests to be
219-
processed simultaneously.
216+
* Improved performance by avoiding the overhead of creating and destroying connections for each request.
217+
* Efficient use of resources by sharing connections among multiple threads.
218+
* Concurrency and parallelism, allowing multiple requests to be processed simultaneously.
219+
220+
benchmark: (demo/demo_thread_pool.rb)
221+
222+
** Benchmark Ruby 3.4.8 vs Ruby 4.0.0 **
220223

221224
benchmark: (demo/demo_thread_pool.rb)
222225

226+
| ruby | runtime (s) | thread | time/thread (s) |
227+
|------|------------:|-------:|----------------:|
228+
| 3.4.8 | 0.018644 | 4 | 0.004661 |
229+
| 4.0.0 | 0.017302 | 4 | 0.004326 |
230+
231+
Ruby 4.0.0 shows a slight improvement over Ruby 3.4.8, but the difference is not significant using thread.
232+
Ractor could be considered for a more efficient use of resources but it's still in the experimental stage.
233+
234+
Note: in this benchmark, `thread == HTTP connections`.
235+
223236
### Real world search without persistency
224237

225238
```ruby

0 commit comments

Comments
 (0)