Skip to content

Commit

Permalink
docs: add docusaurus website content
Browse files Browse the repository at this point in the history
Co-authored-by: João Pereira Rodrigues [email protected]
  • Loading branch information
JoaoRodriguesGithub committed Feb 5, 2024
1 parent 95ddd6c commit e190d0f
Show file tree
Hide file tree
Showing 28 changed files with 501 additions and 558 deletions.
25 changes: 24 additions & 1 deletion .github/workflows/deploy-website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,29 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'

- run: dotnet tool install --global gsferreira.XmlDocMarkdown.Docusaurus --version 0.0.1-beta2 # using this version while the Pull Request isn't accepted here: https://github.com/ejball/XmlDocMarkdown/pull/126
shell: bash

- name: .NET Publish
run: dotnet publish LoadShedding.sln -c Release -o ./drop

- run: dotnet tool list --global
shell: bash

- run: xmldocmd-docusaurus ./drop/Farfetch.LoadShedding.dll website/docs/reference/Farfetch.LoadShedding --type-folders
shell: bash

- run: xmldocmd-docusaurus ./drop/Farfetch.LoadShedding.AspNetCore.dll website/docs/reference/Farfetch.LoadShedding.AspNetCore --type-folders
shell: bash

- run: xmldocmd-docusaurus ./drop/Farfetch.LoadShedding.Prometheus.dll website/docs/reference/Farfetch.LoadShedding.Prometheus --type-folders
shell: bash

- uses: actions/setup-node@v3
with:
node-version: 18
Expand All @@ -34,4 +57,4 @@ jobs:
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./website/build
publish_dir: ./website/build
23 changes: 23 additions & 0 deletions .github/workflows/test-deploy-website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,29 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'

- run: dotnet tool install --global gsferreira.XmlDocMarkdown.Docusaurus --version 0.0.1-beta2 # using this version while the Pull Request isn't accepted here: https://github.com/ejball/XmlDocMarkdown/pull/126
shell: bash

- name: .NET Publish
run: dotnet publish LoadShedding.sln -c Release -o ./drop

- run: dotnet tool list --global
shell: bash

- run: xmldocmd-docusaurus ./drop/Farfetch.LoadShedding.dll website/docs/reference/Farfetch.LoadShedding --type-folders
shell: bash

- run: xmldocmd-docusaurus ./drop/Farfetch.LoadShedding.AspNetCore.dll website/docs/reference/Farfetch.LoadShedding.AspNetCore --type-folders
shell: bash

- run: xmldocmd-docusaurus ./drop/Farfetch.LoadShedding.Prometheus.dll website/docs/reference/Farfetch.LoadShedding.Prometheus --type-folders
shell: bash

- uses: actions/setup-node@v3
with:
node-version: 18
Expand Down
10 changes: 9 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ Here are a few things you can do that will increase the likelihood of your pull

You can find a Makefile with steps for running using docker on the repository root.

## Running git worflows locally

You can build and test workflows locally with [act](https://github.com/nektos/act):
- Follow the [instructions](https://github.com/nektos/act?tab=readme-ov-file#installation) to install act
- To check all available actions: `act -l`
- To run the default (push) event: `act`
- To run a specific job: `act -j build-test`

## Resources

- [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/)
Expand All @@ -43,4 +51,4 @@ You can find a Makefile with steps for running using docker on the repository ro

By sending us your contributions, you are agreeing that your contribution is made subject to the terms of our [Contributor Ownership Statement](https://github.com/Farfetch/.github/blob/master/COS.md)

[code-of-conduct]: CODE_OF_CONDUCT.md
[code-of-conduct]: CODE_OF_CONDUCT.md
127 changes: 18 additions & 109 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,125 +1,34 @@
# LoadShedding
# LoadShedding · [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/farfetch/loadshedding/blob/main/LICENSE) [![nuget version](https://img.shields.io/nuget/v/loadshedding.svg?style=flat)](https://www.nuget.org/packages/LoadShedding/) ![Build Master](https://github.com/Farfetch/loadshedding/workflows/Build/badge.svg?branch=master)

This library provides a set of capabilities to enable the service to deal with requests overload and resource limits to avoid outages and to ensure the best usage of the service capacity.
## Introduction

## Documentation

<details open="open">
<summary>Getting Started</summary>

- [Installation](docs/getting_started/installation.md)
- Register Limits
- [Concurrency Adaptative Limiter](docs/getting_started/register_concurrency_adaptative_limiter.md)
- [Samples](samples)

</details>

## Samples

For sample projects showcasing the application types, dependencies and features please check the [samples](samples/) folder.

## Contributing

Read our [contributing guidelines](CONTRIBUTING.md) to learn about our development process, how to propose bugfixes and improvements, and how to build and test your changes.

### Requirements

- Makefile
- .NET 6
- Docker
- Docker Compose

#### Makefile - Simplify Tests and Build commands

**Important: You must have the Make app installed and configured in your local environment.**

With the makefile present in the Load-Shedding, the teams or engineers who want to contribute to the development of the Load-Shedding library, have a simplified way to run the tests and build the project, the commands are shown below and will wrap and use the same commands that the ones used in the pipeline.

Note: You should be in the root folder of the repository locally, to allow you run the commands.
⚡️ LoadShedding was designed to effectively manage concurrency in the .NET ecosystem.

### Building
🏗 Built upon the foundational principles and concepts pioneered by [Netflix](https://netflixtechblog.medium.com/performance-under-load-3e6fa9a60581).

To build the solution file, you can simply use this command.
🎁 Offers out-of-the-box Adaptative Concurrency Limiter implementation.

```bash
make build
```
🎁 Offers additional features like metrics, request prioritization, and configuration flexibility.

#### Testing (Unit)
## Installation

To run all the tests, you can simply use this command.
[Read the docs](https://farfetch.github.io/loadshedding/docs/getting-started/installation) for any further information.

```bash
make unit-tests
```

The command will build the solution and then run all the tests present and marked as Unit tests.

#### Testing (Integration)

To run all the integration tests, you can simply use this command.

```bash
make integration-tests
```

The command will build the solution and then run all the integration tests.

### Benchmark

Below, it is possible to see a benchmark analysis of the concurrency control mechanism, for this test multiple scenarios were created:

- **Limiter_Default:** Directly tests the AdaptiveConcurrencyLimiter with default priority;
- **Limiter_RandomPriority:** Directly tests the AdaptiveConcurrencyLimiter with random priorities;
- **LimiterMiddleware_Default:** Tests the ConcurrencyLimiterMiddleware that uses the AdaptiveConcurrencyLimiter with Http Requests context with default priority.
- **LimiterMiddleware_RandomPriority:** Tests the ConcurrencyLimiterMiddleware that uses the AdaptiveConcurrencyLimiter with Http Requests context with random priorities.

- **TaskQueueWith1000Items_EnqueueFixedPriority:** Tests the TaskQueue.Enqueue pre-loaded with 1000 items and a default priority;
- **TaskQueueEmpty_EnqueueRandomPriority:** Tests the TaskQueue.Enqueue with no elements;
- **TaskQueueWith1000Items_EnqueueRandomPriority:** Tests the TaskQueue.Enqueue pre-loaded with 1000 items and random priorities;
- **TaskQueueWith1000Items_Dequeue:** Tests the TaskQueue.Dequeue pre-loaded with 1000 items;
- **TaskQueue_EnqueueNewItem_LimitReached:** Tests the TaskQueue.Enqueue pre-loaded with 1000 items and the queue limit reached;

#### Limiter

``` ini
BenchmarkDotNet=v0.13.4, OS=Windows 10 (10.0.19044.2604/21H2/November2021Update)
Intel Core i7-10610U CPU 1.80GHz, 1 CPU, 8 logical and 4 physical cores
.NET SDK=7.0.103
[Host] : .NET 6.0.14 (6.0.1423.7309), X64 RyuJIT AVX2
Job-VLMTWN : .NET 6.0.14 (6.0.1423.7309), X64 RyuJIT AVX2

IterationCount=10
```
## Documentation

| Method | Mean | Error | StdDev | Min | Max | Rank | Completed Work Items | Lock Contentions | Gen0 | Allocated |
|--------------------------------- |---------:|---------:|---------:|---------:|---------:|-----:|---------------------:|-----------------:|-------:|----------:|
| Limiter_Default | 354.4 ns | 6.22 ns | 3.25 ns | 349.2 ns | 358.4 ns | 1 | 0.0000 | - | 0.1450 | 608 B |
| Limiter_RandomPriority | 366.3 ns | 4.82 ns | 2.52 ns | 363.6 ns | 369.6 ns | 2 | 0.0000 | - | 0.1450 | 608 B |
| LimiterMiddleware_Default | 436.6 ns | 28.55 ns | 16.99 ns | 416.7 ns | 471.4 ns | 3 | 0.0000 | - | 0.1855 | 776 B |
| LimiterMiddleware_RandomPriority | 468.7 ns | 6.55 ns | 3.90 ns | 463.7 ns | 475.3 ns | 4 | 0.0000 | - | 0.2027 | 848 B |
Learn more about using LoadShedding on the [site](https://farfetch.github.io/loadshedding/docs)!

##### TaskQueue
## Contributing

``` ini
BenchmarkDotNet=v0.13.4, OS=Windows 10 (10.0.19044.2604/21H2/November2021Update)
Intel Core i7-10610U CPU 1.80GHz, 1 CPU, 8 logical and 4 physical cores
.NET SDK=7.0.103
[Host] : .NET 6.0.14 (6.0.1423.7309), X64 RyuJIT AVX2
Job-THBOTE : .NET 6.0.14 (6.0.1423.7309), X64 RyuJIT AVX2
Read our [contributing guidelines](CONTRIBUTING.md) to learn about our development process, how to propose bugfixes and improvements, and how to build and test your changes.

InvocationCount=1 IterationCount=10 UnrollFactor=1
## Get in touch

```
You can find us at:

| Method | Mean | Error | StdDev | Min | Max | Rank | Completed Work Items | Lock Contentions | Allocated |
|--------------------------------------------- |----------:|----------:|----------:|---------:|----------:|-----:|---------------------:|-----------------:|----------:|
| TaskQueueWith1000Items_EnqueueFixedPriority | 11.311 μs | 3.8278 μs | 2.2779 μs | 6.800 μs | 14.800 μs | 4 | - | - | 896 B |
| TaskQueueEmpty_EnqueueRandomPriority | 6.700 μs | 3.8089 μs | 2.2666 μs | 4.800 μs | 11.800 μs | 2 | - | - | 896 B |
| TaskQueueWith1000Items_EnqueueRandomPriority | 3.650 μs | 0.3540 μs | 0.1852 μs | 3.400 μs | 4.000 μs | 1 | - | - | 896 B |
| TaskQueueWith1000Items_Dequeue | 5.500 μs | 1.0912 μs | 0.5707 μs | 4.600 μs | 6.400 μs | 2 | - | - | 704 B |
| TaskQueue_EnqueueNewItem_LimitReached | 8.111 μs | 2.2848 μs | 1.3596 μs | 7.000 μs | 10.500 μs | 3 | - | - | 1144 B |
- [GitHub Issues](https://github.com/Farfetch/loadshedding/issues)
- [GitHub Discussions](https://github.com/Farfetch/loadshedding/discussions)

#### Conclusion
## License

In all the scenarios the time added to the execution pipeline is very small and the impact caused by the limiter and task queue can be ignored.
LoadShedding is a free and open source project, released under the permissible [MIT license](LICENSE).
25 changes: 0 additions & 25 deletions docs/getting_started/installation.md

This file was deleted.

105 changes: 0 additions & 105 deletions docs/getting_started/quickstart.md

This file was deleted.

Loading

0 comments on commit e190d0f

Please sign in to comment.