{"id":14774977,"url":"https://github.com/fractaledmind/euruko-2024","last_synced_at":"2025-04-28T10:26:17.962Z","repository":{"id":257463963,"uuid":"853335126","full_name":"fractaledmind/euruko-2024","owner":"fractaledmind","description":"Workshop on SQLite on Rails 7.2 apps","archived":false,"fork":false,"pushed_at":"2024-11-10T14:19:58.000Z","size":2781,"stargazers_count":18,"open_issues_count":1,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-28T10:26:15.866Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fractaledmind.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-09-06T13:02:23.000Z","updated_at":"2025-04-16T03:58:57.000Z","dependencies_parsed_at":"2024-09-16T23:40:49.649Z","dependency_job_id":"f40ec21e-4204-4381-84fa-4f8c247d69bc","html_url":"https://github.com/fractaledmind/euruko-2024","commit_stats":null,"previous_names":["fractaledmind/euruko-2024"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fractaledmind%2Feuruko-2024","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fractaledmind%2Feuruko-2024/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fractaledmind%2Feuruko-2024/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fractaledmind%2Feuruko-2024/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fractaledmind","download_url":"https://codeload.github.com/fractaledmind/euruko-2024/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251293704,"owners_count":21566137,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-16T23:01:23.085Z","updated_at":"2025-04-28T10:26:17.930Z","avatar_url":"https://github.com/fractaledmind.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# README\n\nThis is an app built for demonstration purposes for the [EuRuKo 2024 conference](https://2024.euruko.org) held in Sarajevo, Bosnia \u0026 Herzegovina on September 11-13, 2024.\n\nThe application is a basic \"Hacker News\" style app with `User`s, `Post`s, and `Comment`s. The seeds file will create ~100 users, ~1,000 posts, and ~10 comments per post (so ~10,000 comments). Every user has the same password: `password`, so you can sign in as any user to test the app.\n\nThis application runs on Ruby \u003e= 3.1, Rails 7.2.1, and SQLite 3.46.1 (gem version 2.0.4).\n\n## Setup\n\nFirst you need to clone the repository to your local machine:\n\n```sh\ngit clone git@github.com:fractaledmind/euruko-2024.git\ncd euruko-2024\n```\n\nAfter cloning the repository, install the dependencies:\n\n```sh\nbundle install\n```\n\nI have built the repository to be usable out-of-the-box. It contains a seeded production database, precompiled assets, and a binscript to start the server in production mode. The only other things you will need besides the RubyGems dependencies are multiple different Ruby versions and the load testing tool `oha`.\n\n### Setup Ruby Versions\n\nBy default, this repository uses Ruby 3.1.6, which is the most recent point release on the 3.1 branch. As a part of the exploration of the performance impact of different Ruby versions on SQLite-backed Rails applications, we will  be testing the following Ruby versions:\n\n```\nruby-3.3.5\nruby-3.2.5\nruby-3.1.6\n```\n\nPlease make sure you have each of these Ruby versions installed on your machine. If you are using `rbenv`, you can install them with commands like the following:\n\n```sh\nrbenv install 3.3.5\n```\n\nOr, if you are using `asdf`, you can install them like so:\n\n```sh\nasdf install ruby 3.3.5\n```\n\nIf you manage Ruby versions some other way, I'm sure you know how to install new Ruby versions with your tool of choice.\n\n### Setup Load Testing\n\nLoad testing can be done using the [`oha` CLI utility](https://github.com/hatoo/oha), which can be installed on MacOS via [homebrew](https://brew.sh):\n\n```sh\nbrew install oha\n```\n\nand on Windows via [winget](https://github.com/microsoft/winget-cli):\n\n```sh\nwinget install hatoo.oha\n```\n\nor using their [precompiled binaries](https://github.com/hatoo/oha?tab=readme-ov-file#installation) on other platforms.\n\n## Load Testing\n\nThroughout this workshop, we will be load testing the application to observe how our various changes impact the performance of the application. In order to perform the load testing, you will need to run the web server in the `production` environment. I have provided a binscript to make this easier. To start the production server, run the following command:\n\n```sh\nbin/serve\n```\n\nThis simply a shortcut for the following command:\n\n```sh\nRAILS_ENV=production RELAX_SSL=true RAILS_LOG_LEVEL=warn WEB_CONCURRENCY=10 RAILS_MAX_THREADS=5 bin/rails server\n```\n\nThe `RELAX_SSL` environment variable is necessary to allow you to use `http://localhost`. The `RAILS_LOG_LEVEL` is set to `warn` to reduce the amount of logging output. Set `WEB_CONCURRENCY` to the number of cores you have on your laptop. I am on an M1 Macbook Pro with 10 cores, and thus I set the value to 10. The `RAILS_MAX_THREADS` controls the number of threads per worker. I left it at the default of 5, but you can tweak it to see how it affects performance.\n\nWith your server running in one terminal window, you can use the load testing utility to test the app in another terminal window. Here is the shape of the command you will use to test the app:\n\n```sh\noha -c N -z 10s -m POST http://localhost:3000/benchmarking/PATH\n```\n\n`N` is the number of concurrent requests that `oha` will make. I recommend running a large variety of different scenarios with different values of `N`. Personally, I scale up from 1 to 256 concurrent requests, doubling the number of concurrent requests each time. In general, when `N` matches your `WEB_CONCURRENCY` number, this is mostly likely the sweet spot for this app.\n\n`PATH` can be any of the benchmarking paths defined in the app. The app has a few different paths that you can test. From the `routes.rb` file:\n\n```ruby\nnamespace :benchmarking do\n  post \"post_create\"\n  post \"comment_create\"\n  post \"post_destroy\"\n  post \"comment_destroy\"\n  post \"post_show\"\n  post \"posts_index\"\n  post \"user_show\"\nend\n```\n\nYou can validate that the application is properly set up for load testing by serving the application in one terminal window/tab (via `bin/serve`) and then running the following `curl` command in another terminal window/tab:\n\n```sh\ncurl -s -o /dev/null -w \"%{http_code}\" -X POST http://localhost:3000/benchmarking/posts_index\n```\n\nIf this returns `200`, then next ensure that you can run an `oha` command like the following:\n\n```sh\noha -c 1 -z 1s -m POST http://localhost:3000/benchmarking/posts_index\n```\n\nIf this runs successfully, then you are ready to begin the workshop.\n\n## Workshop\n\nYou will find the workshop instructions in the `workshop/` directory. The workshop is broken down into a series of steps, each of which is contained in a separate markdown file. The workshop is designed to be self-guided, but I am available to help if you get stuck. Please feel free to reach out to me on Twitter at [@fractaledmind](https://twitter.com/fractaledmind) if you have any questions.\n\nThe first step is to [run some baseline load tests](workshop/00-run-baseline-load-tests.md). Once you have completed that step, you can move on to the next step, which will be linked at the bottom of each step.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffractaledmind%2Feuruko-2024","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffractaledmind%2Feuruko-2024","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffractaledmind%2Feuruko-2024/lists"}