Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Heartbeat based on network traffic #98

Merged
merged 2 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cloud/google/workers.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def GenerateWorkers(context, hostname_manager, hostname_nfs_server, worker):

docker_image = worker.get('workerImage', context.properties['seuronImage'])

oom_canary_cmd = GenerateDockerCommand(docker_image, docker_env) + ' ' + "python utils/memory_monitor.py ${AIRFLOW__CELERY__BROKER_URL} bot-message-queue >& /dev/null"
oom_canary_cmd = GenerateDockerCommand(docker_image, docker_env + ['--network host']) + ' ' + "python utils/memory_monitor.py ${AIRFLOW__CELERY__BROKER_URL} bot-message-queue >& /dev/null"

if worker['type'] == 'gpu':
cmd = GenerateCeleryWorkerCommand(docker_image, docker_env+['-p 8793:8793'], queue=worker['type'], concurrency=worker['concurrency'])
Expand Down
13 changes: 12 additions & 1 deletion utils/memory_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,18 @@ def run_oom_canary():
if cpu_usage > 20:
logging.info(f"{cpu_usage}% cpu used, heartbeat")
redis_conn.set(hostname, datetime.now().timestamp())
sleep(1)
continue
counters_start = psutil.net_io_counters()
sleep(1)
counters_end = psutil.net_io_counters()
download_speed = counters_end.bytes_recv - counters_start.bytes_recv
upload_speed = counters_end.bytes_sent - counters_start.bytes_sent
if download_speed > 1e6 or upload_speed > 1e6:
logging.info(f"Significant network IO: {download_speed/1e6}MB/s, {upload_speed/1e6}MB/s, heartbeat")
redis_conn.set(hostname, datetime.now().timestamp())
continue
else:
sleep(1)
else:
sleep(t)

Expand Down