Skip to content

Commit

Permalink
Merge pull request #211 from telefonicaid/feature/cluster-support-pre…
Browse files Browse the repository at this point in the history
…landing

Update IoTA with the last changes of the IoTAgent Node Lib (final landing)
  • Loading branch information
AlvaroVega authored Nov 4, 2019
2 parents 5651a4c + 0215408 commit e7e2d14
Show file tree
Hide file tree
Showing 16 changed files with 498 additions and 80 deletions.
1 change: 1 addition & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"quotmark": "single",
"undef": true,
"unused": true,
"esversion": 6,
"trailing": true,
"maxparams": 8,
"maxdepth": 4,
Expand Down
6 changes: 5 additions & 1 deletion CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
- Fix: support to lazy attributes and commands based in NGSIv2 (#104)
- Fix: support to lwm2m client that separe object instances using spaces (#209)
- Fix: default southbound non secure port from 5684 to 5683 (#206)
- Fix: default southbound non secure port from 5684 to 5683 (#206)
- NOTE: in the "upgrade iotagent-node-lib from X to Y" include a mention to configure multi-threading using cluster
nodejs module (through multiCore config.js parameter or IOTA_MULTI_CORE)
- Correct typos in documentation files
- Add lwm2m agent version in the description of /iot/about request
10 changes: 7 additions & 3 deletions bin/lwm2mAgent.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,26 @@
*/
'use strict';

var iotAgent = require('../lib/iotAgentLwm2m'),
let iotAgent = require('../lib/iotAgentLwm2m'),
iotAgentLib = require('iotagent-node-lib'),
info = require('../package.json'),
context = {
op: 'IOTAgent.Executable'
},
logger = require('logops');

function start() {
var config;
let config;

if (process.argv.length === 3) {
config = require('../' + process.argv[2]);
} else {
config = require('../config');
}

iotAgent.start(config, function(error) {
config.ngsi.iotaVersion = info.version;

iotAgentLib.startServer(config, iotAgent, function(error) {
if (error) {
logger.error(context, 'Error starting Agent: [%s] Exiting process', error);
} else {
Expand Down
6 changes: 6 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,10 @@ config.ngsi = {
//clientSecret: 'IOTA_AUTH_CLIENT_SECRET'
//};

/**
* flag indicating whether the node server will be executed in multi-core option (true) or it will be a
* single-thread one (false).
*/
// config.multiCore = true;

module.exports = config;
40 changes: 40 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,43 @@ Currently, this `_FILE` suffix is supported for:
- `IOTA_AUTH_PASSWORD`
- `IOTA_AUTH_CLIENT_ID`
- `IOTA_AUTH_CLIENT_SECRET`

## Best Practices

### Increase ULIMIT in Docker Production Deployments

Default settings for ulimit on a Linux system assume that several users would share the system. These settings limit the
number of resources used by each user. The default settings are generally very low for high performance servers and
should be increased. By default, we recommend, that the Lightweight OMA M2M IoTAgent server in high performance
scenarios, the following changes to ulimits:

```console
ulimit -n 65535 # nofile: The maximum number of open file descriptors (most systems do not allow this
value to be set)
ulimit -c unlimited # core: The maximum size of core files created
ulimit -l unlimited # memlock: The maximum size that may be locked into memory
```

If you are just doing light testing and development, you can omit these settings, and everything will still work.

To set the ulimits in your container, you will need to run Lightweight OMA M2M IoTAgent Docker containers with the
following additional --ulimit flags:

```console
docker run --ulimit nofile=65535:65535 --ulimit core=100000000:100000000 --ulimit memlock=100000000:100000000 \
--name iotagent -d fiware/lightweightm2m-iotagent
```

Since “unlimited” is not supported as a value, it sets the core and memlock values to 100 GB. If your system has more
than 100 GB RAM, you will want to increase this value to match the available RAM on the system.

> Note: The --ulimit flags only work on Docker 1.6 or later.

Nevertheless, you have to "request" more resources (i.e. multiple cores), which might be more difficult for orchestrates
([Docker Engine](https://docs.docker.com/engine) or [Kubernetes](https://kubernetes.io)) to schedule than a few
different containers requesting one core (or less...) each (which it can, in turn, schedule on multiple nodes, and not
necessarily look for one node with enough available cores).

If you want to get more details about the configuration of the system and node.js for high performance scenarios, please
refer to the
[Administration Guide](https://fiware-iotagent-lwm2m.readthedocs.io/en/latest/administrationGuide/index.html).
Loading

0 comments on commit e7e2d14

Please sign in to comment.