lightweightm2m-iotagent icon indicating copy to clipboard operation
lightweightm2m-iotagent copied to clipboard

BUG Monopolization of two resources CPU and MongoDB queries

Open cesarjorgemartinez opened this issue 2 years ago • 0 comments

Partial related to issue: https://github.com/telefonicaid/lightweightm2m-iotagent/issues/193

Detected in: Version 1.5.1 a bit of CPU consumption and MongoDB queries Version 1.6.0 => notable increase CPU consumption and MongoDB queries

Two cases: Using Docker => reach at maximum CPU usage by container instance Using Kubernetes => reach at maximum CPU usage defined at the maximum resource definition

State: Initial deployment without any data, empty.

Symptoms: Using Docker: in a machine of 4 CPUs consuming permanently 50% of 400% Using Kubernetes: Reach at maximum CPU usage defined at the maximum resource definition

Workaroud: Explicit limit of CPU usage => but it is not acceptable

What happens in MongoDB?: One query find almost every 1 millisecond over devices collection of own IOTA database:

{
	"op" : "query",
	"ns" : "iotagent-lightweightm2m.devices",
	"command" : {
		"find" : "devices",
		"filter" : {
			
		},
		"projection" : {
			
		},
		"returnKey" : false,
		"showRecordId" : false,
		"lsid" : {
			"id" : UUID("30098f68-09e6-4f49-b387-a8276dee9319")
		},
		"$clusterTime" : {
			"clusterTime" : Timestamp(1674756656, 1),
			"signature" : {
				"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
				"keyId" : 0
			}
		},
		"$db" : "iotagent-lightweightm2m"
	},
	"keysExamined" : 0,
	"docsExamined" : 0,
	"cursorExhausted" : true,
	"numYield" : 0,
	"nreturned" : 0,
	"locks" : {
		"ReplicationStateTransition" : {
			"acquireCount" : {
				"w" : NumberLong(1)
			}
		},
		"Global" : {
			"acquireCount" : {
				"r" : NumberLong(1)
			}
		},
		"Database" : {
			"acquireCount" : {
				"r" : NumberLong(1)
			}
		},
		"Collection" : {
			"acquireCount" : {
				"r" : NumberLong(1)
			}
		},
		"Mutex" : {
			"acquireCount" : {
				"r" : NumberLong(1)
			}
		}
	},
	"flowControl" : {
		
	},
	"responseLength" : 245,
	"protocol" : "op_msg",
	"millis" : 0,
	"rateLimit" : 1,
	"planSummary" : "COLLSCAN",
	"execStats" : {
		"stage" : "COLLSCAN",
		"nReturned" : 0,
		"executionTimeMillisEstimate" : 0,
		"works" : 2,
		"advanced" : 0,
		"needTime" : 1,
		"needYield" : 0,
		"saveState" : 0,
		"restoreState" : 0,
		"isEOF" : 1,
		"direction" : "forward",
		"docsExamined" : 0
	},
	"ts" : ISODate("2023-01-26T18:11:04.604Z"),
	"client" : "10.128.6.249",
	"allUsers" : [ ],
	"user" : ""
}

Additionally in 1.6.0: In logs multiple circular references possibly related to: https://jira.mongodb.org/browse/NODE-2536 https://www.mongodb.com/community/forums/t/warning-accessing-non-existent-property-count-of-module-exports-inside-circular-dependency/3183/13

Or others...

You are welcome to contribute any ideas to correct this problem

Regards, Cesar Jorge

cesarjorgemartinez avatar Feb 01 '23 16:02 cesarjorgemartinez