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

feat: Network transport (2) - TCP/KCP protocol can be switched by cfg #1895

Merged
merged 5 commits into from
Jul 10, 2024

Conversation

michaljurecko
Copy link
Contributor

@michaljurecko michaljurecko commented Jul 9, 2024

Jira: https://keboola.atlassian.net/browse/PSGO-597

See #1894

Changes:


KCP is on localhost 2-3x slower than TCP, but it is expected.

  • TCP runs in kernel space and has various optimalization for localhost.
  • KCP runs in user space and its benefits can be seen on real networks (see projects like: kcptun, frp, syncthing, ...)

dataSize = 100MB - both protocols are fast enough up to 500MB/s on localhost.

image

Read more (quic is another R-UDP protocol, the principle is the same):

@michaljurecko michaljurecko changed the title feat: Network transport () feat: Network transport (2) Jul 9, 2024
@michaljurecko michaljurecko force-pushed the michaljurecko-PSGO-591-network-transport-2 branch 2 times, most recently from e133727 to a2089b8 Compare July 9, 2024 12:05
Comment on lines 18 to 29

- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
android: false
dotnet: true
haskell: false
large-packages: false
docker-images: false
swap-storage: false

- name: Setup Go, tools and caching
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(maybe it needs some better fix, It looks like, the linter cache is growing and growing)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michaljurecko We are encoutering this issue in other PRs. Should we disable caching if the linter cache is growing? Currently I do not have much space to investigate it.

Copy link
Contributor Author

@michaljurecko michaljurecko Jul 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jachym-tousek-keboola Petr needs the fix, I am mergin it, you comment will be addresed in next PRs, if any.

@michaljurecko michaljurecko force-pushed the michaljurecko-PSGO-591-network-transport-2 branch 4 times, most recently from 807d4f0 to 2acaa38 Compare July 9, 2024 13:00
@michaljurecko michaljurecko changed the title feat: Network transport (2) feat: Network transport (2) - TCP/KCP protocol can be switched by cfg Jul 9, 2024
@michaljurecko michaljurecko force-pushed the michaljurecko-PSGO-591-network-transport-2 branch from 2acaa38 to df4487b Compare July 9, 2024 13:12
Comment on lines +70 to +71
c.SetACKNoDelay(true) // send data immediately, needed for bigger payloads
c.SetNoDelay(1, 10, 2, 1)
Copy link
Contributor Author

@michaljurecko michaljurecko Jul 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For context, why?

During testing of upper layers, I found that writing 100MB takes 5s to write.

It didn't fit in any way with the previous experiments that I did when I was choosing the protocol.

That's why I added the TCP protocol there, for comparison.

Finally, after a few hours, I realized that I forgot to set SetACKNoDelay(true), which makes the difference.

Otherwise, it waits for the next sending window, triggered by a timer.

It makes sense for small messages that are smaller than an UDP packet (~1KB), but for our 10KB+ records it slows down the write (we have buffers in the pipeline).

Copy link

Stream Kubernetes Diff [CI]

Between base 679b6e7 ⬅️ head 582ec36.

Expand
--- /tmp/artifacts/test-k8s-state.old.json.processed.kv	2024-07-10 06:42:14.169618260 +0000
+++ /tmp/artifacts/test-k8s-state.new.json.processed.kv	2024-07-10 06:42:14.617623054 +0000
@@ -13 +13 @@
-<ConfigMap/stream-config>.data["config.yaml"] = "###############################################################################################...
+<ConfigMap/stream-config>.data["config.yaml"] = "###############################################################################################...
@@ -194 +194 @@
-<Deployment/stream-api>.spec.template.spec.containers[0].image = "docker.io/keboola/stream-api:95f6057-1720593118";
+<Deployment/stream-api>.spec.template.spec.containers[0].image = "docker.io/keboola/stream-api:582ec36-1720593493";
@@ -352 +352 @@
-<Deployment/stream-http-source>.spec.template.spec.containers[0].image = "docker.io/keboola/stream-api:95f6057-1720593118";
+<Deployment/stream-http-source>.spec.template.spec.containers[0].image = "docker.io/keboola/stream-api:582ec36-1720593493";
@@ -507 +507 @@
-<Deployment/stream-storage-coordinator>.spec.template.spec.containers[0].image = "docker.io/keboola/stream-api:95f6057-1720593118";
+<Deployment/stream-storage-coordinator>.spec.template.spec.containers[0].image = "docker.io/keboola/stream-api:582ec36-1720593493";
@@ -1186,2 +1186,2 @@
-<Pod/stream-api-<hash>>.spec.containers[0].image = "docker.io/keboola/stream-api:95f6057-1720593118";
-<Pod/stream-api-<hash>>.spec.containers[0].image = "docker.io/keboola/stream-api:95f6057-1720593118";
+<Pod/stream-api-<hash>>.spec.containers[0].image = "docker.io/keboola/stream-api:582ec36-1720593493";
+<Pod/stream-api-<hash>>.spec.containers[0].image = "docker.io/keboola/stream-api:582ec36-1720593493";
@@ -1506 +1506 @@
-<Pod/stream-etcd-0>.spec.containers[0].env[21].value = "new";
+<Pod/stream-etcd-0>.spec.containers[0].env[21].value = "existing";
@@ -1748 +1748 @@
-<Pod/stream-etcd-1>.spec.containers[0].env[21].value = "new";
+<Pod/stream-etcd-1>.spec.containers[0].env[21].value = "existing";
@@ -2056,2 +2056,2 @@
-<Pod/stream-http-source-<hash>>.spec.containers[0].image = "docker.io/keboola/stream-api:95f6057-1720593118";
-<Pod/stream-http-source-<hash>>.spec.containers[0].image = "docker.io/keboola/stream-api:95f6057-1720593118";
+<Pod/stream-http-source-<hash>>.spec.containers[0].image = "docker.io/keboola/stream-api:582ec36-1720593493";
+<Pod/stream-http-source-<hash>>.spec.containers[0].image = "docker.io/keboola/stream-api:582ec36-1720593493";
@@ -2436,2 +2436,2 @@
-<Pod/stream-storage-coordinator-<hash>>.spec.containers[0].image = "docker.io/keboola/stream-api:95f6057-1720593118";
-<Pod/stream-storage-coordinator-<hash>>.spec.containers[0].image = "docker.io/keboola/stream-api:95f6057-1720593118";
+<Pod/stream-storage-coordinator-<hash>>.spec.containers[0].image = "docker.io/keboola/stream-api:582ec36-1720593493";
+<Pod/stream-storage-coordinator-<hash>>.spec.containers[0].image = "docker.io/keboola/stream-api:582ec36-1720593493";
@@ -2663 +2663 @@
-<Pod/stream-storage-writer-reader-0>.spec.containers[0].image = "docker.io/keboola/stream-api:95f6057-1720593118";
+<Pod/stream-storage-writer-reader-0>.spec.containers[0].image = "docker.io/keboola/stream-api:582ec36-1720593493";
@@ -2739 +2739 @@
-<Pod/stream-storage-writer-reader-0>.spec.containers[1].image = "docker.io/keboola/stream-api:95f6057-1720593118";
+<Pod/stream-storage-writer-reader-0>.spec.containers[1].image = "docker.io/keboola/stream-api:582ec36-1720593493";
@@ -2910 +2910 @@
-<Pod/stream-storage-writer-reader-1>.spec.containers[0].image = "docker.io/keboola/stream-api:95f6057-1720593118";
+<Pod/stream-storage-writer-reader-1>.spec.containers[0].image = "docker.io/keboola/stream-api:582ec36-1720593493";
@@ -2986 +2986 @@
-<Pod/stream-storage-writer-reader-1>.spec.containers[1].image = "docker.io/keboola/stream-api:95f6057-1720593118";
+<Pod/stream-storage-writer-reader-1>.spec.containers[1].image = "docker.io/keboola/stream-api:582ec36-1720593493";
@@ -3038 +3038 @@
-<Pod/stream-storage-writer-reader-1>.spec.volumes[0].persistentVolumeClaim.claimName = "medium-001-stream-storage-writer-reader-1";
+<Pod/stream-storage-writer-reader-1>.spec.volumes[0].persistentVolumeClaim.claimName = "fast-001-stream-storage-writer-reader-1";
@@ -3041 +3041 @@
-<Pod/stream-storage-writer-reader-1>.spec.volumes[1].persistentVolumeClaim.claimName = "slow-001-stream-storage-writer-reader-1";
+<Pod/stream-storage-writer-reader-1>.spec.volumes[1].persistentVolumeClaim.claimName = "medium-001-stream-storage-writer-reader-1";
@@ -3044 +3044 @@
-<Pod/stream-storage-writer-reader-1>.spec.volumes[2].persistentVolumeClaim.claimName = "fast-001-stream-storage-writer-reader-1";
+<Pod/stream-storage-writer-reader-1>.spec.volumes[2].persistentVolumeClaim.claimName = "slow-001-stream-storage-writer-reader-1";
@@ -3228 +3228 @@
-<ReplicaSet/stream-api-<hash>>.spec.template.spec.containers[0].image = "docker.io/keboola/stream-api:95f6057-1720593118";
+<ReplicaSet/stream-api-<hash>>.spec.template.spec.containers[0].image = "docker.io/keboola/stream-api:582ec36-1720593493";
@@ -3393 +3393 @@
-<ReplicaSet/stream-http-source-<hash>>.spec.template.spec.containers[0].image = "docker.io/keboola/stream-api:95f6057-1720593118";
+<ReplicaSet/stream-http-source-<hash>>.spec.template.spec.containers[0].image = "docker.io/keboola/stream-api:582ec36-1720593493";
@@ -3555 +3555 @@
-<ReplicaSet/stream-storage-coordinator-<hash>>.spec.template.spec.containers[0].image = "docker.io/keboola/stream-api:95f6057-1720593118";
+<ReplicaSet/stream-storage-coordinator-<hash>>.spec.template.spec.containers[0].image = "docker.io/keboola/stream-api:582ec36-1720593493";
@@ -3596,0 +3597,12 @@
+<Secret/sh.helm.release.v1.stream-etcd.v2> = {};
+<Secret/sh.helm.release.v1.stream-etcd.v2>.apiVersion = "v1";
+<Secret/sh.helm.release.v1.stream-etcd.v2>.data = {};
+<Secret/sh.helm.release.v1.stream-etcd.v2>.kind = "Secret";
+<Secret/sh.helm.release.v1.stream-etcd.v2>.metadata = {};
+<Secret/sh.helm.release.v1.stream-etcd.v2>.metadata.labels = {};
+<Secret/sh.helm.release.v1.stream-etcd.v2>.metadata.labels.name = "stream-etcd";
+<Secret/sh.helm.release.v1.stream-etcd.v2>.metadata.labels.owner = "helm";
+<Secret/sh.helm.release.v1.stream-etcd.v2>.metadata.labels.version = "2";
+<Secret/sh.helm.release.v1.stream-etcd.v2>.metadata.name = "sh.helm.release.v1.stream-etcd.v2";
+<Secret/sh.helm.release.v1.stream-etcd.v2>.metadata.namespace = "stream";
+<Secret/sh.helm.release.v1.stream-etcd.v2>.type = "helm.sh/release.v1";
@@ -3862 +3874 @@
-<StatefulSet/stream-etcd>.spec.template.spec.containers[0].env[21].value = "new";
+<StatefulSet/stream-etcd>.spec.template.spec.containers[0].env[21].value = "existing";
@@ -4099 +4111 @@
-<StatefulSet/stream-storage-writer-reader>.spec.template.spec.containers[0].image = "docker.io/keboola/stream-api:95f6057-1720593118";
+<StatefulSet/stream-storage-writer-reader>.spec.template.spec.containers[0].image = "docker.io/keboola/stream-api:582ec36-1720593493";
@@ -4172 +4184 @@
-<StatefulSet/stream-storage-writer-reader>.spec.template.spec.containers[1].image = "docker.io/keboola/stream-api:95f6057-1720593118";
+<StatefulSet/stream-storage-writer-reader>.spec.template.spec.containers[1].image = "docker.io/keboola/stream-api:582ec36-1720593493";


(see artifacts in the Github Action for more information)

Copy link
Contributor

@Matovidlo Matovidlo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@jachym-tousek-keboola jachym-tousek-keboola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good but how did you compare TCP and KCP? Did you write some benchmarks?

@michaljurecko
Copy link
Contributor Author

Looks good but how did you compare TCP and KCP? Did you write some benchmarks?

There is test, which logs write duration, see code.

If you want, write a benchmark, but as I wrote, it will not be sufficiently descriptive on localhost.

I only needed such a simple comparison to find the issue, so the test was enough.

@michaljurecko michaljurecko merged commit a9a876c into main Jul 10, 2024
14 checks passed
@michaljurecko michaljurecko deleted the michaljurecko-PSGO-591-network-transport-2 branch July 10, 2024 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants