Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow disk-based persistence to be completely disabled #2228

Merged
merged 39 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
a187cf6
Allow in-memory Loki and extent store
joelverhagen Oct 15, 2023
af85ace
Update config
joelverhagen Oct 15, 2023
b3846f8
Plumb config
joelverhagen Oct 15, 2023
6532e5a
Switch to newer buffer stream library
joelverhagen Oct 15, 2023
d00464e
Add the config in more places and update markdowns
joelverhagen Oct 15, 2023
58aa6f0
Use built-in stream
joelverhagen Oct 16, 2023
a255c7f
Refactor table creation to a single factory
joelverhagen Oct 17, 2023
657879f
Move in-memory persistence to an env var
joelverhagen Oct 17, 2023
fca212e
Add QueueTestServerFactory to centralize test server creation
joelverhagen Oct 17, 2023
c3aee91
Properly handle offset and count in extents
joelverhagen Oct 17, 2023
939291a
Add in-memory tests to all variants
joelverhagen Oct 17, 2023
2ae4746
Fix two flaky tests
joelverhagen Oct 17, 2023
b006592
Make random local files have some newline characters so diff tools ar…
joelverhagen Oct 17, 2023
ba1410b
Use a larger buffer for the download, the test is very slow otherwise
joelverhagen Oct 17, 2023
7d2bf7f
Add design spec
joelverhagen Oct 17, 2023
b0f382f
Add logging to MemoryExtentStore
joelverhagen Oct 17, 2023
481c5d1
Make queue GC logging consistent with blob GC logging
joelverhagen Oct 17, 2023
d7c707a
Add VS Code option
joelverhagen Oct 17, 2023
7379048
Improve setting description
joelverhagen Oct 17, 2023
cda16fb
Don't include docs in the VS Code extension
joelverhagen Oct 18, 2023
cb0a6bb
Merge remote-tracking branch 'azure/main' into in-memory
joelverhagen Oct 20, 2023
a85519d
Fix merge
joelverhagen Oct 20, 2023
a05dfd8
Prevent SQL and in-memory persistence at the same time
joelverhagen Oct 20, 2023
c371f77
Add MemoryExtentChunkStore for shared in-memory size tracking
joelverhagen Oct 20, 2023
350dee7
Use a shared MemoryExtentChunkStore by default
joelverhagen Oct 20, 2023
057df96
Align Table and Queue cleaning approach with Blob
joelverhagen Oct 25, 2023
a028724
Add extentMemoryLimit option per review feedback
joelverhagen Oct 25, 2023
724b733
Merge remote-tracking branch 'azure/main' into in-memory
joelverhagen Oct 25, 2023
afb98fd
Update spec with comments and add note about slower memory release
joelverhagen Oct 25, 2023
0daf51c
Reject --location along with --inMemoryPersistence
joelverhagen Oct 26, 2023
97acd4e
Fail fast on the binary tests if the binaries don't exist
joelverhagen Oct 26, 2023
68938c8
Properly tag tests
joelverhagen Oct 26, 2023
6928602
Polish READMEs
joelverhagen Oct 26, 2023
8d43f65
Address code review comments
joelverhagen Nov 4, 2023
12dee72
Eliminate unnecessary diff noise
joelverhagen Nov 4, 2023
17906ab
Change extentMemoryLimit to use megabytes as the unit
joelverhagen Nov 5, 2023
d9de373
Address comments
joelverhagen Nov 8, 2023
803e27c
Update README
joelverhagen Nov 14, 2023
9b91305
Fix typo
joelverhagen Nov 14, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
41 changes: 41 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@
"skipFiles": ["node_modules/*/**", "<node_internals>/*/**"],
"outputCapture": "std"
},
{
"type": "node",
"request": "launch",
"name": "Azurite Service - Loki, in-memory",
"cwd": "${workspaceFolder}",
"runtimeArgs": ["-r", "ts-node/register"],
"args": ["${workspaceFolder}/src/azurite.ts", "-d", "debug.log", "--inMemoryPersistence"],
"env": {
"AZURITE_ACCOUNTS": ""
},
"skipFiles": ["node_modules/*/**", "<node_internals>/*/**"],
"outputCapture": "std"
},
{
"type": "node",
"request": "launch",
Expand Down Expand Up @@ -204,6 +217,34 @@
"internalConsoleOptions": "openOnSessionStart",
"outputCapture": "std"
},
{
"type": "node",
"request": "launch",
"name": "Current Mocha TS File - Loki, in-memory",
"cwd": "${workspaceFolder}",
"runtimeArgs": ["-r", "ts-node/register"],
"args": [
"${workspaceFolder}/node_modules/mocha/bin/_mocha",
"-u",
"tdd",
"--timeout",
"999999",
"--colors",
"${workspaceFolder}/${relativeFile}"
],
"env": {
"AZURITE_ACCOUNTS": "",
"AZURE_TABLE_STORAGE": "",
"DATATABLES_ACCOUNT_NAME": "<name of your storage account>",
"DATATABLES_ACCOUNT_KEY" : "<account key for your storage account>",
"AZURE_DATATABLES_STORAGE_STRING": "https://<your account name>.table.core.windows.net",
"AZURE_DATATABLES_SAS": "?<sas query string>",
"NODE_TLS_REJECT_UNAUTHORIZED": "0",
"AZURITE_TEST_INMEMORYPERSISTENCE": "true"
blueww marked this conversation as resolved.
Show resolved Hide resolved
},
"internalConsoleOptions": "openOnSessionStart",
"outputCapture": "std"
},
{
"name": "VSC Extension",
"type": "extensionHost",
Expand Down
3 changes: 2 additions & 1 deletion .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ temp
.github
.prettierrc.json
README.mcr.md
release
release
docs
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

## Upcoming Release

General:

- Add `--inMemoryPersistence` and `--extentMemoryLimit` options and related configs to store all data in-memory without disk persistence. (issue #2227)

## 2023.10 Version 3.27.0

General:
Expand Down
50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
- [Certificate Configuration (HTTPS)](#certificate-configuration-https)
- [OAuth Configuration](#oauth-configuration)
- [Skip API Version Check](#skip-api-version-check)
- [Disable Product Style Url](#disable-product-style-url)
- [Use in-memory storage](#use-in-memory-storage)
- [Command Line Options Differences between Azurite V2](#command-line-options-differences-between-azurite-v2)
- [Supported Environment Variable Options](#supported-environment-variable-options)
- [Customized Storage Accounts & Keys](#customized-storage-accounts--keys)
Expand Down Expand Up @@ -198,6 +200,8 @@ Following extension configurations are supported:
- `azurite.oauth` OAuth oauthentication level. Candidate level values: `basic`.
- `azurite.skipApiVersionCheck` Skip the request API version check, by default false.
- `azurite.disableProductStyleUrl` Force parsing storage account name from request Uri path, instead of from request Uri host.
- `azurite.inMemoryPersistence` Disable persisting any data to disk. If the Azurite process is terminated, all data is lost.
- `azurite.extentMemoryLimit` When using in-memory persistence, limit the total size of extents (blob and queue content) to a specific number of megabytes. This does not limit blob, queue, or table metadata. Defaults to 50% of total memory.

### [DockerHub](https://hub.docker.com/_/microsoft-azure-storage-azurite)

Expand Down Expand Up @@ -430,6 +434,52 @@ Optional. When using FQDN instead of IP in request Uri host, by default Azurite
--disableProductStyleUrl
```

### Use in-memory storage

Optional. Disable persisting any data to disk and only store data in-memory. If the Azurite process is terminated, all
data is lost. By default, LokiJS persists blob and queue metadata to disk and content to extent files. Table storage
persists all data to disk. This behavior can be disabled using this option. This setting is rejected when the SQL based
metadata implementation is enabled (via `AZURITE_DB`). This setting is rejected when the `--location` option is
specified.

```cmd
--inMemoryPersistence
joelverhagen marked this conversation as resolved.
Show resolved Hide resolved
```

By default, the in-memory extent store (for blob and queue content) is limited to 50% of the total memory on the host
machine. This is evaluated to using [`os.totalmem()`](https://nodejs.org/api/os.html#ostotalmem). This limit can be
overridden using the `--extentMemoryLimit <megabytes>` option. There is no restriction on the value specified for this
option but virtual memory may be used if the limit exceeds the amount of available physical memory as provided by the
operating system. A high limit may eventually lead to out of memory errors or reduced performance.

As blob or queue content (i.e. bytes in the in-memory extent store) is deleted, the memory is not freed immediately.
Similar to the default file-system based extent store, both the blob and queue service have an extent garbage collection
(GC) process. This process is in addition to the standard Node.js runtime GC. The extent GC periodically detects unused
extents and deletes them from the extent store. This happens on a regular time period rather than immediately after
the blob or queue REST API operation that caused some content to be deleted. This means that process memory consumed by
the deleted blob or queue content will only be released after both the extent GC and the runtime GC have run. The extent
GC will remove the reference to the in-memory byte storage and the runtime GC will free the unreferenced memory some
time after that. The blob extent GC runs every 10 minutes and the queue extent GC runs every 1 minute.

The queue and blob extent storage count towards the same limit. The `--extentMemoryLimit` setting is rejected when
`--inMemoryPersistence` is not specified. LokiJS storage (blob and queue metadata and table data) does
not contribute to this limit and is unbounded which is the same as without the `--inMemoryPersistence` option.

```cmd
--extentMemoryLimit <megabytes>
```

This option is rejected when `--inMemoryPersistence` is not specified.

When the limit is reached, write operations to the blob or queue endpoints which carry content will fail with an `HTTP
409` status code, a custom storage error code of `MemoryExtentStoreAtSizeLimit`, and a helpful error message.
Well-behaved storage SDKs and tools will not a retry on this failure and will return a related error message. If this
error is met, consider deleting some in-memory content (blobs or queues), raising the limit, or restarting the Azurite
server thus resetting the storage completely.

Note that if many hundreds of megabytes of content (queue message or blob content) are stored in-memory, it can take
noticeably longer than usual for the process to terminate since all the consumed memory needs to be released.

### Command Line Options Differences between Azurite V2

Azurite V3 supports SharedKey, Account Shared Access Signature (SAS), Service SAS, OAuth, and Public Container Access authentications, you can use any Azure Storage SDKs or tools like Storage Explorer to connect Azurite V3 with any authentication strategy.
Expand Down
60 changes: 60 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ jobs:
displayName: "npm run test:blob"
env: {}

- script: |
npm run test:blob:in-memory
workingDirectory: "./"
displayName: "npm run test:blob:in-memory"
env: {}

- job: blobtestubuntu22_04
displayName: Blob Test Linux Ubuntu 22.04
pool:
Expand Down Expand Up @@ -65,6 +71,12 @@ jobs:
displayName: "npm run test:blob"
env: {}

- script: |
npm run test:blob:in-memory
workingDirectory: "./"
displayName: "npm run test:blob:in-memory"
env: {}

- job: blobtestwin
displayName: Blob Test Windows
pool:
Expand Down Expand Up @@ -92,6 +104,12 @@ jobs:
displayName: "npm run test:blob"
env: {}

- script: |
npm run test:blob:in-memory
workingDirectory: "./"
displayName: "npm run test:blob:in-memory"
env: {}

- job: blobtestmac
displayName: Blob Test Mac
pool:
Expand Down Expand Up @@ -119,6 +137,12 @@ jobs:
displayName: "npm run test:blob"
env: {}

- script: |
npm run test:blob:in-memory
workingDirectory: "./"
displayName: "npm run test:blob:in-memory"
env: {}

- job: blobtestmysql
displayName: Blob Test Mysql
pool:
Expand Down Expand Up @@ -181,6 +205,12 @@ jobs:
displayName: "npm run test:queue"
env: {}

- script: |
npm run test:queue:in-memory
workingDirectory: "./"
displayName: "npm run test:queue:in-memory"
env: {}

- job: queuetestwin
displayName: Queue Test Windows
pool:
Expand Down Expand Up @@ -208,6 +238,12 @@ jobs:
displayName: "npm run test:queue"
env: {}

- script: |
npm run test:queue:in-memory
workingDirectory: "./"
displayName: "npm run test:queue:in-memory"
env: {}

- job: queuetestmac
displayName: Queue Test Mac
pool:
Expand Down Expand Up @@ -235,6 +271,12 @@ jobs:
displayName: "npm run test:queue"
env: {}

- script: |
npm run test:queue:in-memory
workingDirectory: "./"
displayName: "npm run test:queue:in-memory"
env: {}

- job: tabletestlinux
displayName: Table Test Linux
pool:
Expand Down Expand Up @@ -263,6 +305,12 @@ jobs:
displayName: "npm run test:table"
env: {}

- script: |
npm run test:table:in-memory
workingDirectory: "./"
displayName: "npm run test:table:in-memory"
env: {}

- job: tabletestwin
displayName: Table Test Windows
pool:
Expand Down Expand Up @@ -291,6 +339,12 @@ jobs:
displayName: "npm run test:table"
env: {}

- script: |
npm run test:table:in-memory
workingDirectory: "./"
displayName: "npm run test:table:in-memory"
env: {}

- job: tabletestmac
displayName: Table Test Mac
pool:
Expand Down Expand Up @@ -319,6 +373,12 @@ jobs:
displayName: "npm run test:table"
env: {}

- script: |
npm run test:table:in-memory
workingDirectory: "./"
displayName: "npm run test:table:in-memory"
env: {}

- job: azuritenodejslinux
displayName: Azurite Linux
pool:
Expand Down