Skip to content

Guide for adding support of πŸš€ ClusterWS in the Meteor

Notifications You must be signed in to change notification settings

mrauhu/meteor-clusterws

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 

Repository files navigation

β˜„ Meteor + πŸš€ ClusterWS

How to make the Meteor consume less CPU and RAM

Use stream-server-uws

See also: meteor/meteor#10120

Introduction

By default, the Meteor Stream Server using the SockJS library for handling WebSocket messages of the Distributed Data Protocol (DDP).

The advantage of the SockJS library is that if the WebSocket protocol are not supported by a browser, then it allows you to use alternative transports.

The disadvantage it is eating CPU and RAM, and with a large number of DDP connections and messages, the memory starts to leak.

Can I use WebSockets only?

This solution based on the ClusterWS/cWS β€” C++ WebSocket implementation for Node.js.

How to use it now

Prerequisites

Open your project:

cd your-project-root

If your project not a Git repository then initialize it:

git init

Installing

  1. Replace ddp-server and socket-stream-client, install disable-sockjs, stream-server and stream-server-uws packages via Git:

    git submodule add https://github.com/mrauhu/ddp-server packages/ddp-server
    git submodule add https://github.com/mrauhu/disable-sockjs packages/disable-sockjs
    git submodule add https://github.com/mrauhu/socket-stream-client packages/socket-stream-client
    git submodule add https://github.com/mrauhu/stream-server packages/stream-server
    git submodule add https://github.com/mrauhu/stream-server-uws packages/stream-server-uws
  2. Enable Stream Server with the @clusterws/cws:

    meteor add stream-server-uws

Usage

Run the Meteor:

meteor

Have fun

Thanks

Sergey N