Skip to content

Commit 693d004

Browse files
committed
Merge branch 'main' into sidebar-nav/add-cluster-deployment-patterns-guide
2 parents 4984281 + 4040f1a commit 693d004

File tree

16 files changed

+645
-13
lines changed

16 files changed

+645
-13
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
---
2+
tags:
3+
- Enterprise Standard
4+
- Enterprise Premium
5+
displayed_sidebar: docsEnglish
6+
---
7+
8+
# ScalarDB Cluster Deployment Patterns for Microservices
9+
10+
When building microservice applications that use ScalarDB Cluster, there are two patterns you can choose for how to deploy ScalarDB Cluster: shared-cluster pattern and separated-cluster pattern.
11+
This document first explains those patterns, how they differ, and the basic guidelines on which one to choose in which cases.
12+
13+
Also, this document assumes that your microservice applications are created based on the database-per-service pattern, where each microservice manages its database, and a microservice needs to access another microservice's database via APIs between the microservices.
14+
15+
## ScalarDB Cluster deployment patterns
16+
17+
In the shared-cluster pattern, microservices share one ScalarDB Cluster instance, which is a cluster of ScalarDB Cluster nodes, in a system, so they access the same ScalarDB Cluster instance to interact with their databases. On the other hand, in the separated-cluster pattern, microservices use several ScalarDB Cluster instances. Typically, one microservice accesses one ScalarDB Cluster instance to interact with its database.
18+
19+
The following diagram shows the patterns. (MS stands for microservice.)
20+
21+
![ScalarDB Cluster deployment patterns for microservices.](images/scalardb-deployment-patterns.png)
22+
23+
:::note
24+
25+
You also need to manage the Coordinator table in either pattern in addition to the databases required for microservices.
26+
27+
:::
28+
29+
## Pros and cons
30+
31+
One obvious difference is the amount of resources for ScalarDB Cluster instances. With the separated-cluster pattern, you need more resources to manage your applications. This also incurs more maintenance burden and costs.
32+
33+
In addition, the ScalarDB Cluster APIs that you would need to use are different. Specifically, for the shared-cluster pattern, you need to use the [one-phase commit interface](../api-guide.mdx#transactional-api), where only one microservice needs to call `commit` to commit a transaction after microservices read and write records. For the separated-cluster pattern, you need to use the [two-phase commit interface](../two-phase-commit-transactions.mdx), where all the microservices first need to call `prepare` and then call `commit` if all the prepare calls are successful. Therefore, microservices with the separated-cluster pattern will likely be more complex than microservices with the shared-cluster pattern because they need to handle transactions and their errors in a more fine-grained manner.
34+
35+
Moreover, the level of resource isolation is different. Microservices should be well-isolated for better maintainability and development efficiency, but the shared-cluster pattern brings weaker resource isolation. Weak resource isolation might also bring weak security. However, security risks can be mitigated by using the security features of ScalarDB Cluster, like authentication and authorization.
36+
37+
Similarly, there is a difference in how systems are administrated. Specifically, in the shared-cluster pattern, a team must be tasked with managing a ScalarDB Cluster instance on behalf of the other teams. Typically, the central data team can manage it, but issues may arise if no such team exists. With the separated-cluster pattern, administration is more balanced but has a similar issue for the Coordinator table. The issue can be addressed by having a microservice for coordination and making a team manage the microservice.
38+
39+
The following is a summary of the pros and cons of the patterns.
40+
41+
### Shared-cluster pattern
42+
43+
- **Pros:**
44+
- Simple transaction and error handling because of the one-phase commit interface. (Backup operations for databases can also be simple.)
45+
- Less resource usage because it uses one ScalarDB Cluster instance.
46+
- **Cons:**
47+
- Weak resource isolation between microservices.
48+
- Unbalanced administration. (One team needs to manage a ScalarDB Cluster instance on behalf of the others.)
49+
50+
### Separated-cluster pattern
51+
52+
- **Pros:**
53+
- Better resource isolation.
54+
- More balanced administration. (A team manages one microservice and one ScalarDB Cluster instance. Also, a team must be tasked with managing the Coordinator table.)
55+
- **Cons:**
56+
- Complex transaction and error handling due to the two-phase commit interface. (Backup operations for databases can also be complex.)
57+
- More resource usage because of several ScalarDB Cluster instances.
58+
59+
## Which pattern to choose
60+
61+
Using the shared-cluster pattern is recommended whenever possible. Although the shared-cluster pattern has some disadvantages, as described above, its simplicity and ease of management outweigh those disadvantages. Moreover, since ScalarDB Cluster stores all critical states in their underlying databases and does not hold any critical states in its memory, it can be seen as just a path to the databases. Therefore, we believe a system with the shared-cluster pattern still complies with the database-per-service pattern and does not violate the microservice philosophy much.
62+
63+
If the cons of the shared-cluster pattern are not acceptable, you can still use the separated-cluster pattern. However, you should use that pattern only if you properly understand the mechanism and usage of the two-phase commit interface. Otherwise, you might face some issues, like database anomalies.
64+
65+
## Limitations
66+
67+
ScalarDB provides several APIs, such as CRUD, SQL, and Spring Data JDBC. Although the CRUD and SQL interfaces support both the shared-cluster and separated-cluster patterns, the Spring Data JDBC interface does not support the shared-cluster pattern. This is because its one-phase commit interface currently assumes an application is monolithic, where it is not divided into microservices that interact with each other. The Spring Data JDBC interface supports the two-phase commit interface and the separated-cluster pattern, just as the other APIs do.
68+
69+
## See also
70+
71+
- [Transactions with a Two-Phase Commit Interface](../two-phase-commit-transactions.mdx)
72+
187 KB
Loading

docs/scalardb-core-status-codes.mdx

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ tags:
66
displayed_sidebar: docsEnglish
77
---
88

9-
# ScalarDB Error Codes
9+
# ScalarDB Core Error Codes
1010

11-
This page provides a list of error codes in ScalarDB.
11+
This page provides a list of error codes in ScalarDB Core.
1212

1313
## Error code classes and descriptions
1414

@@ -1157,6 +1157,54 @@ The variable key column size must be greater than or equal to 64
11571157
The value of the column %s in the primary key contains an illegal character. Primary-key columns must not contain any of the following characters in Cosmos DB: ':', '/', '\', '#', '?'. Value: %s
11581158
```
11591159

1160+
### `CORE-10146`
1161+
1162+
**Message**
1163+
1164+
```markdown
1165+
Inserting already-written data is not allowed
1166+
```
1167+
1168+
### `CORE-10147`
1169+
1170+
**Message**
1171+
1172+
```markdown
1173+
Deleting already-inserted data is not allowed
1174+
```
1175+
1176+
### `CORE-10148`
1177+
1178+
**Message**
1179+
1180+
```markdown
1181+
Invalid key: Column %s does not exist in the table %s in namespace %s.
1182+
```
1183+
1184+
### `CORE-10149`
1185+
1186+
**Message**
1187+
1188+
```markdown
1189+
Invalid base64 encoding for blob value for column %s in table %s in namespace %s
1190+
```
1191+
1192+
### `CORE-10150`
1193+
1194+
**Message**
1195+
1196+
```markdown
1197+
Invalid number specified for column %s in table %s in namespace %s
1198+
```
1199+
1200+
### `CORE-10151`
1201+
1202+
**Message**
1203+
1204+
```markdown
1205+
Method null argument not allowed
1206+
```
1207+
11601208
## `CORE-2xxxx` status codes
11611209

11621210
### `CORE-20000`
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
tags:
3+
- Enterprise Standard
4+
- Enterprise Premium
5+
displayed_sidebar: docsJapanese
6+
---
7+
8+
# マイクロサービスにおける ScalarDB Cluster のデプロイパターン
9+
10+
import TranslationBanner from '/src/components/_translation-ja-jp.mdx';
11+
12+
<TranslationBanner />
13+
14+
ScalarDB Cluster を使用するマイクロサービスアプリケーションを構築する場合、ScalarDB Cluster のデプロイ方法として、共有クラスターパターンと分離クラスターパターンの2つのパターンを選択できます。
15+
このドキュメントでは、まずこれらのパターンについて説明し、それらの違いと、どの場合にどちらを選択するかの基本的なガイドラインを示します。
16+
17+
また、このドキュメントでは、マイクロサービスアプリケーションが database-per-service パターンに基づいて作成されているものと想定しています。このパターンでは、各マイクロサービスがデータベースを管理し、マイクロサービスはマイクロサービス間の API を介して別のマイクロサービスのデータベースにアクセスする必要があります。
18+
19+
## ScalarDB Cluster のデプロイパターン
20+
21+
共有クラスターパターンでは、マイクロサービスはシステム内で1つの ScalarDB Cluster インスタンス (ScalarDB Cluster ノードのクラスタ) を共有するため、同じ ScalarDB Cluster インスタンスにアクセスしてデータベースとやり取りします。一方、分離クラスターパターンでは、マイクロサービスは複数の ScalarDB Cluster インスタンスを使用します。通常、1つのマイクロサービスが1つの ScalarDB Cluster インスタンスにアクセスして、データベースとやり取りします。
22+
23+
次の図は2つのパターンを示しています。(MS はマイクロサービスの略です。)
24+
25+
![マイクロサービスにおける ScalarDB Cluster のデプロイパターン。](images/scalardb-deployment-patterns.png)
26+
27+
:::note
28+
29+
どちらのパターンでも、マイクロサービスに必要なデータベースに加えて、Coordinator テーブルも管理する必要があります。
30+
31+
:::
32+
33+
## 長所と短所
34+
35+
明らかな違いの1つは、ScalarDB Cluster インスタンスのリソースの量です。分離クラスターパターンでは、アプリケーションを管理するためのリソースが増えます。これにより、メンテナンスの負担とコストも増加します。
36+
37+
さらに、使用する ScalarDB Cluster API も異なります。具体的には、共有クラスターパターンの場合、[1フェーズコミットインターフェース](../api-guide.mdx#transactional-api)を使用する必要があります。このインターフェースでは、マイクロサービスがレコードを読み書きした後、1つのマイクロサービスのみが `commit` を呼び出してトランザクションをコミットします。分離クラスターパターンの場合、[2フェーズコミットインターフェース](../two-phase-commit-transactions.mdx)を使用する必要があります。このインターフェースでは、すべてのマイクロサービスが最初に `prepare` を呼び出し、すべての`prepare` 呼び出しが成功した場合に `commit` を呼び出します。したがって、分離クラスターパターンのマイクロサービスは、トランザクションとそのエラーをよりきめ細かい方法で処理する必要があるため、共有クラスターパターンのマイクロサービスよりも複雑になる可能性があります。
38+
39+
さらに、リソースの分離レベルも異なります。マイクロサービスは、保守性と開発効率を高めるために十分に分離されている必要がありますが、共有クラスターパターンではリソースの分離が弱くなります。リソースの分離が弱いと、セキュリティも弱くなる可能性があります。ただし、認証や承認などの ScalarDB Cluster のセキュリティ機能を使用することで、セキュリティリスクを軽減できます。
40+
41+
同様に、システムの管理方法にも違いがあります。具体的には、共有クラスターパターンでは、他のチームに代わって ScalarDB Cluster インスタンスを管理するタスクをチームに割り当てる必要があります。通常は中央データチームが管理しますが、そのようなチームが存在しない場合は問題が発生する可能性があります。分離クラスターパターンでは、管理のバランスがより取れていますが、Coordinator テーブルに関して同様の問題が発生します。この問題は、調整用のマイクロサービスを用意し、1つのチームにそのマイクロサービスを管理させることで対処できます。
42+
43+
次に、パターンの長所と短所をまとめます。
44+
45+
### 共有クラスターパターン
46+
47+
- **長所:**
48+
- 1フェーズコミットインターフェースのため、トランザクションとエラーの処理が簡単です。(データベースのバックアップ操作も簡単です。)
49+
- 1つの ScalarDB Cluster インスタンスを使用するため、リソース使用量が少なくなります。
50+
- **短所:**
51+
- マイクロサービス間のリソース分離が弱い。
52+
- 管理のバランスが取れていない。(1つのチームが他のチームに代わって ScalarDB Cluster インスタンスを管理する必要があります。)
53+
54+
### 分離クラスターパターン
55+
56+
- **利点:**
57+
- リソースの分離が向上します。
58+
- 管理のバランスがより取れます。(1つのチームが1つのマイクロサービスと1つの ScalarDB Cluster インスタンスを管理します。また、1つのチームに Coordinator ターテーブルの管理を任せる必要があります。)
59+
- **欠点:**
60+
- 2フェーズコミットインターフェースによるトランザクションとエラー処理が複雑です。(データベースのバックアップ操作も複雑になることがあります。)
61+
- 複数の ScalarDB Cluster インスタンスがあるため、リソース使用量が増加します。
62+
63+
64+
## どのパターンを選択するか
65+
66+
可能な限り、共有クラスターパターンを使用することをお勧めします。共有クラスターパターンには前述のようにいくつかの欠点がありますが、そのシンプルさと管理のしやすさはそれらの欠点を上回ります。さらに、ScalarDB Cluster はすべての重要な状態を基盤となるデータベースに保存し、メモリには重要な状態を保持しないため、データベースへの単なるパスとして見ることができます。したがって、共有クラスターパターンのシステムは依然としてサービスごとのデータベースパターンに準拠しており、マイクロサービスの理念にあまり違反していないと考えています。
67+
68+
共有クラスターパターンの欠点が受け入れられない場合は、分離クラスターパターンを使用できます。ただし、2フェーズコミットインターフェースのメカニズムと使用方法を適切に理解している場合にのみ、このパターンを使用してください。そうでない場合、データベースの異常などの問題が発生する可能性があります。
69+
70+
## 制限事項
71+
72+
ScalarDB は、CRUD、SQL、Spring Data JDBC などのいくつかの API を提供します。 CRUD および SQL インターフェースは共有クラスターパターンと分離クラスターパターンの両方をサポートしていますが、Spring Data JDBC インターフェースは共有クラスターパターンをサポートしていません。これは、Spring Data JDBC の1フェーズコミットインターフェースが現在、アプリケーションがモノリシックであり、相互にやり取りするマイクロサービスに分割されていないことを前提としているためです。Spring Data JDBC インターフェースは、他の API と同様に、2フェーズコミットインターフェースと分離クラスターパターンをサポートしています。
73+
74+
## 参照
75+
76+
- [2フェーズコミットインターフェースを使用したトランザクション](../two-phase-commit-transactions.mdx)
187 KB
Loading

i18n/versioned_docs/ja-jp/docusaurus-plugin-content-docs/current/scalardb-core-status-codes.mdx

Lines changed: 53 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ tags:
66
displayed_sidebar: docsJapanese
77
---
88

9-
# ScalarDB エラーコード
9+
# ScalarDB Core エラーコード
1010

1111
import TranslationBanner from '/src/components/_translation-ja-jp.mdx';
1212

1313
<TranslationBanner />
1414

15-
このページでは、ScalarDB のエラーコードの一覧を示します。
15+
このページでは、ScalarDB Core のエラーコードの一覧を示します。
1616

1717
## エラーコードのクラスと説明
1818

@@ -206,7 +206,7 @@ The clustering key is not properly specified. Operation: %s
206206
**メッセージ**
207207

208208
```markdown
209-
The encryption feature is not enabled. To encrypt data at rest, you must enable this feature. Note that this feature is supported only in the ScalarDB Enterprise edition
209+
The authentication and authorization feature is not enabled. To use this feature, you must enable it. Note that this feature is supported only in the ScalarDB Enterprise edition
210210
```
211211

212212
### `CORE-10023`
@@ -1142,7 +1142,7 @@ This operation is supported only when no conditions are specified. If you want t
11421142
**メッセージ**
11431143

11441144
```markdown
1145-
ScalarDB Transparent Data Encryption is not enabled. To use ScalarDB Transparent Data Encryption, you must enable it. Note that this feature is supported only in the ScalarDB Enterprise edition
1145+
The encryption feature is not enabled. To encrypt data at rest, you must enable this feature. Note that this feature is supported only in the ScalarDB Enterprise edition
11461146
```
11471147

11481148
### `CORE-10144`
@@ -1161,6 +1161,54 @@ The variable key column size must be greater than or equal to 64
11611161
The value of the column %s in the primary key contains an illegal character. Primary-key columns must not contain any of the following characters in Cosmos DB: ':', '/', '\', '#', '?'. Value: %s
11621162
```
11631163

1164+
### `CORE-10146`
1165+
1166+
**メッセージ**
1167+
1168+
```markdown
1169+
Inserting already-written data is not allowed
1170+
```
1171+
1172+
### `CORE-10147`
1173+
1174+
**メッセージ**
1175+
1176+
```markdown
1177+
Deleting already-inserted data is not allowed
1178+
```
1179+
1180+
### `CORE-10148`
1181+
1182+
**メッセージ**
1183+
1184+
```markdown
1185+
Invalid key: Column %s does not exist in the table %s in namespace %s.
1186+
```
1187+
1188+
### `CORE-10149`
1189+
1190+
**メッセージ**
1191+
1192+
```markdown
1193+
Invalid base64 encoding for blob value for column %s in table %s in namespace %s
1194+
```
1195+
1196+
### `CORE-10150`
1197+
1198+
**メッセージ**
1199+
1200+
```markdown
1201+
Invalid number specified for column %s in table %s in namespace %s
1202+
```
1203+
1204+
### `CORE-10151`
1205+
1206+
**メッセージ**
1207+
1208+
```markdown
1209+
Method null argument not allowed
1210+
```
1211+
11641212
## `CORE-2xxxx` ステータスコード
11651213

11661214
### `CORE-20000`
@@ -1610,7 +1658,7 @@ Fetching the next result failed
16101658
**メッセージ**
16111659

16121660
```markdown
1613-
Rolling back the transaction failed
1661+
Rolling back the transaction failed. Details: %s
16141662
```
16151663

16161664
### `CORE-30030`

0 commit comments

Comments
 (0)