litestack 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 025c78f9b04863bfce9f09dae2181b735187d0ff8852ff0a474ce59fc4f3b7fc
4
- data.tar.gz: f4d950cbfef0e9b0e6642196b2efa0953dd8d988de54168ff9934bb257d6c729
3
+ metadata.gz: 52b25ab2fd70ef40c8199c431e07638853915a131036abb52d1fef267a70cb13
4
+ data.tar.gz: 8f2bcf6c6fbc6d50e18664f74235b4242c79faa65317b1dcd7263ed0aa928161
5
5
  SHA512:
6
- metadata.gz: 29bb82387bac7b66cf2e335fc072ff79613de006ead064cbbf01746b1c57687b47c5bf875af7e173273ca8ba961dfc561595dfb9fd1527f92989444e294be4ea
7
- data.tar.gz: ae523a47ebeed583670541bec755c39559e6a24230aaf7fa074e262a7410e64dd6e5c4f82af9b9d40dc8ef39748bac6bc38656a00a2a0066957a10af02573a9e
6
+ metadata.gz: 1fa0edf72ea893a29f71f7398f685954243dd2cbd61080624ff91f49f389bf067c76cac491520f91c7f2470f568444d37eff0b72787d5f8418d6abbc869fd7c8
7
+ data.tar.gz: 75be276d72526cc1f68e204929822c8ba846b1d476d2d429de5c5e2e298df748b62de9d5c804912384ddec515505e6a42e0d9e09e4f27a3d27ff942f423a904c
data/BENCHMARKS.md ADDED
@@ -0,0 +1,104 @@
1
+ # Litestack Benchmarks
2
+
3
+ This is a set of initial (simple) benchmars, designed to understand the baseline performance for different litestack components against their counterparts.
4
+ These are not real life scenarios and I hope I will be able to produce some interesting ones soon.
5
+
6
+ > ![litedb](https://github.com/oldmoe/litestack/blob/master/assets/litedb_logo_teal.png?raw=true)
7
+
8
+ ### Point Read
9
+
10
+ ```ruby
11
+ Post.find(id) #ActiveRecord
12
+ Post[id] #Sequel
13
+ ```
14
+ This maps to "SELECT * FROM posts WHERE id = ?"
15
+
16
+ |Prcoess Count|ActiveRecord:PostgreSQL|ActiveRecord:litedb|Sequel:PostgreSQL|Sequel:litedb|
17
+ |-:|-:|-:|-:|-:|
18
+ |1|1.3K q/s|6.5K q/s|1.8K q/s|17.4K q/s|
19
+ |2|2.6K q/s|13.9K q/s|3.5K q/s|33.2K q/s|
20
+ |4|4.9K q/s|24.5K q/s|5.9K q/s|58.7K q/s|
21
+ |8|6.9K q/s|31.8K q/s|9.3K q/s|86.6K q/s|
22
+
23
+ ### Multi Reads
24
+
25
+ ```ruby
26
+ Post.where(user_id: id).limit(5) # ActiveRecord and Sequel
27
+ ```
28
+ This maps to "SELECT * FROM posts WHERE user_id = ? LIMIT 5"
29
+
30
+ |Prcoess Count|ActiveRecord:PostgreSQL|ActiveRecord:litedb|Sequel:PostgreSQL|Sequel:litedb|
31
+ |-:|-:|-:|-:|-:|
32
+ |1|345 q/s|482 q/s|937 q/s|1.1K q/s|
33
+ |2|751 q/s|848 q/s|1.3K q/s|2.3K q/s|
34
+ |4|1.4K q/s|1.6K q/s|3.4K q/s|4.0K q/s|
35
+ |8|2.6K q/s|2.8K q/s|5.1K q/s|6.6K q/s|
36
+
37
+ ### Point Update
38
+
39
+ ```ruby
40
+ Post.update(id, {updated_at: updated_at} # ActiveRecord
41
+ Post[id].update({updated_at: updated_at}) # Sequel
42
+ ```
43
+ This maps to "Update posts SET updated_at = ? WHERE id = ?"
44
+
45
+ |Prcoess Count|ActiveRecord:PostgreSQL|ActiveRecord:litedb|Sequel:PostgreSQL|Sequel:litedb|
46
+ |-:|-:|-:|-:|-:|
47
+ |1|125 q/s|484 q/s|129 q/s|2.1K q/s|
48
+ |2|265 q/s|576 q/s|333 q/s|2.5K q/s|
49
+ |4|481 q/s|693 q/s|704 q/s|2.3K q/s|
50
+ |8|898 q/s|748 q/s|1.2K q/s|2.4K q/s|
51
+
52
+ It is clear the Litedb enjoys a clear advantage for reads and is very competitive for updates until many processes are relentlessly trying to write at the same time non stop.
53
+ For most applications, even with higher level of concurrency, Litedb will scale super well for reads and provide a very good baseline for writes.
54
+
55
+ > ![litecache](https://github.com/oldmoe/litestack/blob/master/assets/litecache_logo_teal.png?raw=true)
56
+
57
+ For testing the cache we attempted to try writing and reading different payload sizes with a fixed key size
58
+
59
+ ### Write
60
+
61
+ |Payload Size (bytes)|Redis|litecahce|
62
+ |-:|-:|-:|
63
+ |10|4.2K q/s|11.0K q/s|
64
+ |100|4.7K q/s|11.6K q/s|
65
+ |1000|4.0K q/s|7.0K q/s|
66
+ |10000|3.4K q/s|2.4K q/s|
67
+
68
+ ### Read
69
+
70
+ |Payload Size (bytes)|Redis|litecahce|
71
+ |-:|-:|-:|
72
+ |10|5.0K q/s|69.4K q/s|
73
+ |100|5.0K q/s|90.7K q/s|
74
+ |1000|4.5K q/s|70.9K q/s|
75
+ |10000|3.7K q/s|26.9K q/s|
76
+
77
+ ### Increment an int value
78
+
79
+ |Redis|litecahce|
80
+ |-:|-:|
81
+ |5.1K q/s|16.9K q/s|
82
+
83
+ It is not even a contest! litecache delivers way higher peroformance, specially in reading performance which is arguably the most important metric for a cache.
84
+
85
+ > ![litejob](https://github.com/oldmoe/litestack/blob/master/assets/litejob_logo_teal.png?raw=true)
86
+
87
+ Two scenarios were benchmarked, an empty job and one with a 100ms sleep to simulate moderate to heavy network IO. Sidekiq was tested against litejob
88
+
89
+ ### No-op Job
90
+
91
+ |Sidekiq|Litejob:threads|litejob:fibers|
92
+ |-:|-:|-:|
93
+ |1.4K j/s|1.6K j/s|4.9K j/s|
94
+
95
+ ### IO Simulated Job
96
+
97
+ |Sidekiq: 5 threads|Sidekiq: 25 threads|Litejob:threads|litejob:fibers|
98
+ |-:|-:|-:|-:|
99
+ |48 j/s|239 j/s|457 j/s|3.2K j/s|
100
+
101
+ Running Litejob with fibers is producing much faster results than any threaded solution. Still though, threaded Litejob remains ahead of Sidekiq in all scenarios.
102
+
103
+
104
+
data/README.md CHANGED
@@ -5,6 +5,9 @@ litestack is a revolutionary gem for Ruby and Ruby on Rails that provides an all
5
5
 
6
6
  Compared to conventional approaches that require separate servers and databases, LiteStack offers superior performance, efficiency, ease of use, and cost savings. Its embedded database and cache reduce memory and CPU usage, while its simple interface streamlines the development process. Overall, LiteStack sets a new standard for web application development and is an excellent choice for those who demand speed, efficiency, and simplicity.
7
7
 
8
+ You can read more about why litestack can be a good choice for your next web application **[here](WHYLITESTACK.md)**, you might also be interested in litestack **[benchmarks](BENCHMARKS.md)**.
9
+
10
+
8
11
  litestack provides integration with popular libraries, including:
9
12
 
10
13
  - Rack
@@ -16,9 +19,9 @@ litestack provides integration with popular libraries, including:
16
19
 
17
20
  With litestack you only need to add a single gem to your app which would replace a host of other gems and services, for example, a typical Rails app using litestack will no longer need the following services:
18
21
 
19
- - PostgreSQL
20
- - Redis
21
- - Sidekiq
22
+ - Database Server (e.g. PostgreSQL, MySQL)
23
+ - Cache Server (e.g. Redis, Memcached)
24
+ - Job Processor (e.g. Sidekiq, Goodjob)
22
25
 
23
26
  To make it even more efficient, litestack will detect the presence of Fiber based IO frameworks like Async (e.g. when you use the Falcon web server) or Polyphony. It will then switch its background workers for caches and queues to fibers (using the semantics of the existing framework). This is done transparently and will generally lead to lower CPU and memory utilization.
24
27
 
data/WHYLITESTACK.md CHANGED
@@ -16,6 +16,8 @@ This ease of setup and configuration is due to Litestack's design philosophy, wh
16
16
 
17
17
  This simplicity is a significant advantage for developers, as it allows them to focus on writing code and delivering features rather than dealing with the complexities of database and infrastructure management. By simplifying the setup process, Litestack can help reduce the time and cost required to get your application up and running, enabling you to focus on delivering value to your users.
18
18
 
19
+ That's not to say we hate on complex solutions, actually, we believe complexity has its place, elsewhere!.
20
+
19
21
  ## Simple can be cutting edge
20
22
  Another benefit of Litestack is its deep integration with state of the art Ruby IO libraries like Async and Polyphony. This allows for even greater performance improvements and improved efficiency, as these libraries can help manage concurrency and parallelism in your web application.
21
23
 
@@ -1,15 +1,17 @@
1
1
  #require 'polyphony'
2
2
  require 'async/scheduler'
3
3
  require './bench'
4
- require './skjob.rb'
5
- require './uljob.rb'
6
4
 
7
5
  Fiber.set_scheduler Async::Scheduler.new
8
6
 
9
- count = 1000
7
+ count = 10000
8
+ require './skjob.rb'
9
+ require './uljob.rb'
10
+
11
+ puts Litesupport.environment
10
12
 
11
13
  t = Time.now.to_f
12
- # make sure sidekiq is started with skjob.rb as the job-
14
+ puts "make sure sidekiq is started with skjob.rb as the job"
13
15
  bench("enqueuing sidekiq jobs", count) do |i|
14
16
  SidekiqJob.perform_async(count, t)
15
17
  end
data/bench/queue.db ADDED
Binary file
Binary file
Binary file
data/bench/skjob.rb CHANGED
@@ -4,7 +4,7 @@ class SidekiqJob
4
4
  include Sidekiq::Job
5
5
  @@count = 0
6
6
  def perform(count, time)
7
- sleep 0.01
7
+ sleep 0.1
8
8
  @@count += 1
9
9
  if @@count == count
10
10
  puts "finished in #{Time.now.to_f - time} seconds (#{count / (Time.now.to_f - time)} jps)"
data/bench/uljob.rb CHANGED
@@ -6,7 +6,7 @@ class MyJob
6
6
  @@count = 0
7
7
  # self.queue = :normal
8
8
  def perform(count, time)
9
- sleep 1
9
+ #sleep 0.1
10
10
  @@count += 1
11
11
  if @@count == count
12
12
  puts "UL finished in #{Time.now.to_f - time} seconds (#{count / (Time.now.to_f - time)} jps)"
@@ -32,7 +32,7 @@ class Litejobqueue
32
32
  DEFAULT_OPTIONS = {
33
33
  config_path: "./litejob.yml",
34
34
  path: "./queue.db",
35
- queues: [["default", 1, "spawn"]],
35
+ queues: [["default", 5]],
36
36
  workers: 1,
37
37
  sleep_intervals: [0.001, 0.005, 0.025, 0.125, 0.625, 3.125]
38
38
  }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Litestack
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: litestack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mohamed Hassan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-25 00:00:00.000000000 Z
11
+ date: 2023-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sqlite3
@@ -45,6 +45,7 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
+ - BENCHMARKS.md
48
49
  - CHANGELOG.md
49
50
  - Gemfile
50
51
  - LICENSE.txt
@@ -64,6 +65,9 @@ files:
64
65
  - bench/bench_queue.rb
65
66
  - bench/bench_rails.rb
66
67
  - bench/bench_raw.rb
68
+ - bench/queue.db
69
+ - bench/queue.db-shm
70
+ - bench/queue.db-wal
67
71
  - bench/rails_job.rb
68
72
  - bench/skjob.rb
69
73
  - bench/uljob.rb