meteorhacks / cluster

Clustering solution for Meteor with load balancing and service discovery
https://meteorhacks.com/cluster-a-different-kind-of-load-balancer-for-meteor.html
MIT License
632 stars 80 forks source link

How to balance CPU? #78

Open lorensr opened 9 years ago

lorensr commented 9 years ago

latest versions of both cluster and mup

Is something wrong with my mup.json?

{
  // Server authentication info
  "servers": [
    {
      "host": "ip1"
      "username": ...
      "pem": ...
    },
    {
      "host": "ip2"
      "username": ...
      "pem": ...
    },
    {
      "host": "ip3"
      "username": ...
      "pem": ...
    }
  ],

  "setupMongo": false,
  "setupNode": true,
  "nodeVersion": "0.10.36",
  "setupPhantom": true,
  "appName": "myapp",

  // Location of app (local directory)
  "app": "~/myapp",

  "ssl": {
    "pem": "./ssl.pem"
  },

  "env": {
    "ROOT_URL": "https://myapp.io",
    "MONGO_URL": ...
    "MONGO_OPLOG_URL": ...
    "CLUSTER_DISCOVERY_URL": ...
    "CLUSTER_SERVICE": "web"
  },

  // Meteor Up checks if the app comes online just after the deployment
  // before mup checks that, it will wait for no. of seconds configured below
  "deployCheckWaitTime": 15
}
lorensr commented 9 years ago

Are there better ways to debug whether connections are getting distributed? And can you add this to the readme?

lorensr commented 9 years ago

I just upgraded Kadira to get the ability to show hosts. The one getting most of the sessions is ip1, but it looks like a few might be going to the others – why wouldn't it be evenly distributed? image

elie222 commented 9 years ago

I just ran into a situation where one of my cores was running at 100% CPU and the other at 18%. (Using multicore support for 2 cores)

elie222 commented 9 years ago

Any answers here? I want to move to multi server setup but not good if distribution isn't working properly.

lorensr commented 9 years ago

Using meteor-down, I'm seeing sessions in Kadira get more evenly distributed. CPU on the A-record machine quickly gets to 100% even at concurrency level 1 (70% stud and 30% meteorup). The other machines stay at 10% CPU even at concurrency 100. How much would this imbalance be helped by making some of the other machines balancers? Or do I need to switch to a DNS with round-robin A records to make a big difference? Do balancers do some of the stud work? /cc @arunoda

elie222 commented 9 years ago

I've been seeing the same issues for a 2 core machine. With one process running at 100% CPU and the other at 2% CPU. I'm using nginx as a reverse proxy with ip_hash for balancing across multiple servers for the moment.

elie222 commented 9 years ago

@lorensr I just noticed, shouldn't you be exporting the endpointUrl as an environment variable?

lorensr commented 9 years ago

Looks from the example like it's not needed with mup: https://github.com/meteorhacks/cluster#practical-setup https://gist.github.com/arunoda/13f2e9c22bf526b84556

elie222 commented 9 years ago

Yeah... Mup takes care of it. Just remembered. But what about balancer url?

lorensr commented 9 years ago

No balancers – hence question on whether adding balancers would fix vs rotating A record.

elie222 commented 9 years ago

Well try it. You don't need to do anything with a records to get the balancing working On 4 Aug 2015 01:21, "Loren Sands-Ramshaw" notifications@github.com wrote:

No balancers – hence question on whether adding balancers would fix vs rotating A record.

— Reply to this email directly or view it on GitHub https://github.com/meteorhacks/cluster/issues/78#issuecomment-127420765.

lorensr commented 9 years ago

SSL didn't cover subdomains, and then I had to remove cluster to get hot code reload working.

maxkferg commented 8 years ago

This is normally a problem with the system clock. If the servers' clocks are out of sync by more than 10 seconds, the balancing algorithm breaks down. See #105 for details