Code Monkey home page Code Monkey logo

Comments (5)

Tzelon avatar Tzelon commented on May 23, 2024 3

Thank you for the update. I will try to make stress testing and will update.

from ws-tcp-relay.

antonioaguilar avatar antonioaguilar commented on May 23, 2024 2

Here is the Docker image that I'm using for the testing. Unfortunately, I didn't get to do stress testing so far because I only have one application that connects via WebSocket.

from ws-tcp-relay.

isobit avatar isobit commented on May 23, 2024 1
  1. Unfortunately I haven't done any stress testing; I haven't yet tried to use this in a large scale project, so that's a bit of uncharted territory. This code is extremely simple though, so I imagine a single instance can handle however many concurrently open connections golang.org/x/net/websocket can handle.
  2. Connections are opened as soon as a websocket opening handshake is received (this is handled by golang.org/x/net/websocket). ws-tcp-relay doesn't know anything about NATS since all it does is stream data between websockets and TCP. With regard to websocket-nats, this indeed happens during nats.connect(...), which internally opens the websocket.
  3. Connections are kept open as long as both the websocket and TCP connections remain open. Either the client or server can terminate the connection at any time, so for usage with NATS, gnatsd should handle timeout and keep-alive. Otherwise, it appears that golang.org/x/net/websocket does not implement ping/pong messages, so it may be worth investigating replacing that with something like github.com/gorilla/websocket.

That all being said, your approach sounds like the right way to go, although I would do the "connect to a ws-tcp-relay instance randomly" part using a load balancer rather than in the client. I would be interested to see how you're setting up your Docker instances, it may be helpful for others to include a simple Dockerfile in the project. Also, would it be easier if I published binaries?

from ws-tcp-relay.

antonioaguilar avatar antonioaguilar commented on May 23, 2024

Hi @isobit, thank you for your prompt response. I'll be happy to do some stress testing ;-). Below are some Bash scripts I'm using to get Docker to launch 10 instances of the relay server:

First, you need to launch NATS using Docker:

#!/usr/bin/env bash

docker run -d --rm --name="nats-server" --memory=128M -p 4222:4222 -p 8222:8222 nats
#!/usr/bin/env bash

SERVERS=10
NATS_SERVER_IP="0.0.0.0"
RELAY_SERVER_PORT=6001
COUNT=0

while [ $(($COUNT < $SERVERS)) == 1 ];
do

  docker run -it --rm --name="nats-relay-$COUNT" --memory=128M -p $RELAY_SERVER_PORT:$RELAY_SERVER_PORT golang sh -c "go get github.com/joshglendenning/ws-tcp-relay && exec ws-tcp-relay -p $RELAY_SERVER_PORT $NATS_SERVER_IP:4222"

  echo -e "[$COUNT] - WS-TCP RELAY [$RELAY_SERVER_PORT] STARTED";

  COUNT=$(($COUNT + 1))
  RELAY_SERVER_PORT=$(($RELAY_SERVER_PORT + 1))

done

then you can use docker stats to see the containers running.

I'm in the process of documenting my setup and I will be happy to share it when ready.

from ws-tcp-relay.

Tzelon avatar Tzelon commented on May 23, 2024

Hey, I'm very interested in stress testing. please share your results
Thank you!

from ws-tcp-relay.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.