litestack 0.1.1 → 0.1.3

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: 9f959b5e414b4190205ea516cf7acacf180714fd08f4fca9b90a3c84c2f9d594
4
+ data.tar.gz: 8350f9398d62a481fb656452cd3e4037237c83f292042f1b3db1e56445801a19
5
5
  SHA512:
6
- metadata.gz: 29bb82387bac7b66cf2e335fc072ff79613de006ead064cbbf01746b1c57687b47c5bf875af7e173273ca8ba961dfc561595dfb9fd1527f92989444e294be4ea
7
- data.tar.gz: ae523a47ebeed583670541bec755c39559e6a24230aaf7fa074e262a7410e64dd6e5c4f82af9b9d40dc8ef39748bac6bc38656a00a2a0066957a10af02573a9e
6
+ metadata.gz: 71c6fbd7f51fca6f8a55e86738fc5f28ae1a8452fe3a1a1f1b9cb6944850b71341c728f1eceb40a72b47a8e9f5ca38d07a83db7a7dbc740275bc4df335001032
7
+ data.tar.gz: 4fd49dd8559328728c9be9dbcf2740c9da22606501822877fccb16454b67aa0e7e5ecdc35a870752d9f02557c3e6d3397df6c68005a20543dd7b6dfd09873cda
data/BENCHMARKS.md ADDED
@@ -0,0 +1,113 @@
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 produces
15
+ ```sql
16
+ SELECT * FROM posts WHERE id = ?
17
+ ```
18
+
19
+ |Prcoess Count|ActiveRecord:PostgreSQL|ActiveRecord:litedb|Sequel:PostgreSQL|Sequel:litedb|
20
+ |-:|-:|-:|-:|-:|
21
+ |1|1.3K q/s|6.5K q/s|1.8K q/s|17.4K q/s|
22
+ |2|2.6K q/s|13.9K q/s|3.5K q/s|33.2K q/s|
23
+ |4|4.9K q/s|24.5K q/s|5.9K q/s|58.7K q/s|
24
+ |8|6.9K q/s|31.8K q/s|9.3K q/s|86.6K q/s|
25
+
26
+ ### Multi Reads
27
+
28
+ ```ruby
29
+ Post.where(user_id: id).limit(5) # ActiveRecord and Sequel
30
+ ```
31
+ This produces
32
+ ```sql
33
+ SELECT * FROM posts WHERE user_id = ? LIMIT 5
34
+ ```
35
+
36
+ |Prcoess Count|ActiveRecord:PostgreSQL|ActiveRecord:litedb|Sequel:PostgreSQL|Sequel:litedb|
37
+ |-:|-:|-:|-:|-:|
38
+ |1|345 q/s|482 q/s|937 q/s|1.1K q/s|
39
+ |2|751 q/s|848 q/s|1.3K q/s|2.3K q/s|
40
+ |4|1.4K q/s|1.6K q/s|3.4K q/s|4.0K q/s|
41
+ |8|2.6K q/s|2.8K q/s|5.1K q/s|6.6K q/s|
42
+
43
+ ### Point Update
44
+
45
+ ```ruby
46
+ Post.update(id, {updated_at: updated_at} # ActiveRecord
47
+ Post[id].update({updated_at: updated_at}) # Sequel
48
+ ```
49
+ This produces
50
+ ```sql
51
+ Update posts SET updated_at = ? WHERE id = ?
52
+ ```
53
+
54
+ |Prcoess Count|ActiveRecord:PostgreSQL|ActiveRecord:litedb|Sequel:PostgreSQL|Sequel:litedb|
55
+ |-:|-:|-:|-:|-:|
56
+ |1|125 q/s|484 q/s|129 q/s|2.1K q/s|
57
+ |2|265 q/s|576 q/s|333 q/s|2.5K q/s|
58
+ |4|481 q/s|693 q/s|704 q/s|2.3K q/s|
59
+ |8|898 q/s|748 q/s|1.2K q/s|2.4K q/s|
60
+
61
+ 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.
62
+ For most applications, even with higher level of concurrency, Litedb will scale super well for reads and provide a very good baseline for writes.
63
+
64
+ > ![litecache](https://github.com/oldmoe/litestack/blob/master/assets/litecache_logo_teal.png?raw=true)
65
+
66
+ For testing the cache we attempted to try writing and reading different payload sizes with a fixed key size
67
+
68
+ ### Write
69
+
70
+ |Payload Size (bytes)|Redis|litecahce|
71
+ |-:|-:|-:|
72
+ |10|4.2K q/s|11.0K q/s|
73
+ |100|4.7K q/s|11.6K q/s|
74
+ |1000|4.0K q/s|7.0K q/s|
75
+ |10000|3.4K q/s|2.4K q/s|
76
+
77
+ ### Read
78
+
79
+ |Payload Size (bytes)|Redis|litecahce|
80
+ |-:|-:|-:|
81
+ |10|5.0K q/s|69.4K q/s|
82
+ |100|5.0K q/s|90.7K q/s|
83
+ |1000|4.5K q/s|70.9K q/s|
84
+ |10000|3.7K q/s|26.9K q/s|
85
+
86
+ ### Increment an int value
87
+
88
+ |Redis|litecahce|
89
+ |-:|-:|
90
+ |5.1K q/s|16.9K q/s|
91
+
92
+ 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.
93
+
94
+ > ![litejob](https://github.com/oldmoe/litestack/blob/master/assets/litejob_logo_teal.png?raw=true)
95
+
96
+ 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
97
+
98
+ ### No-op Job
99
+
100
+ |Sidekiq|Litejob:threads|litejob:fibers|
101
+ |-:|-:|-:|
102
+ |1.4K j/s|1.6K j/s|4.9K j/s|
103
+
104
+ ### IO Simulated Job
105
+
106
+ |Sidekiq: 5 threads|Sidekiq: 25 threads|Litejob:threads|litejob:fibers|
107
+ |-:|-:|-:|-:|
108
+ |48 j/s|239 j/s|457 j/s|3.2K j/s|
109
+
110
+ Running Litejob with fibers is producing much faster results than any threaded solution. Still though, threaded Litejob remains ahead of Sidekiq in all scenarios.
111
+
112
+
113
+
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
 
@@ -50,7 +53,7 @@ litestack currently offers three main components
50
53
 
51
54
  > ![litedb](https://github.com/oldmoe/litestack/blob/master/assets/litedb_logo_teal.png?raw=true)
52
55
 
53
- litedb is a wrapper around SQLite3, offering a better default configuration that is tuned for concurrency and performance. Out of the box, litedb works seamlessly between multiple processes without database locking errors. lite db can be used in multiple ways, including:
56
+ litedb is a wrapper around SQLite3, offering a better default configuration that is tuned for concurrency and performance. Out of the box, litedb works seamlessly between multiple processes without database locking errors. litedb can be used in multiple ways, including:
54
57
 
55
58
  #### Direct litedb usage
56
59
 
@@ -66,7 +69,7 @@ db.get_first_value("select count(*) from users") # => 1
66
69
 
67
70
  #### ActiveRecord
68
71
 
69
- litesd provides tight Rails/ActiveRecord integration and can be configured as follows
72
+ litedb provides tight Rails/ActiveRecord integration and can be configured as follows
70
73
 
71
74
  In database.yml
72
75
 
@@ -159,7 +162,7 @@ The queues need to include a name and a priority (a number between 1 and 10) and
159
162
 
160
163
  ## Contributing
161
164
 
162
- Bug reports aree welcome on GitHub at https://github.com/oldmoe/litestack. Please note that this is not an open contribution project and that we don't accept pull requests.
165
+ Bug reports are welcome on GitHub at https://github.com/oldmoe/litestack. Please note that this is not an open contribution project and that we don't accept pull requests.
163
166
 
164
167
  ## License
165
168
 
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/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.3"
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.3
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