shevchenkos / DynamoDbBackUp

46 stars 23 forks source link

Memory leak #9

Open luispabon opened 7 years ago

luispabon commented 7 years ago

We're currently considering this for backing up our DynamoDB tables and we've observed a memory leak.

We've mounted the app in a docker container then deployed into a Kubernetes cluster on AWS:

image

This is after backing up around 200K records into S3 on a full backup.

Our backups never finish as the process ends up exceeding available capacity (max 1.5 GB RAM) at 800K records and they get killed.

Also, the process slows down as memory consumption rises.

snakelab commented 7 years ago

Are you using the lambda-stream-workflow or are you talking from the "backup-full" option?!

luispabon commented 7 years ago

backup-full

luispabon commented 7 years ago
#!/usr/bin/env bash

# Check we have all we need on the environment
if [[ ! "$APP_S3_BUCKET" ]]; then
    printf "\n ** Please provide with APP_S3_BUCKET"
    exit 1
fi

if [[ ! "$APP_TABLE_NAME" ]]; then
    printf "\n ** Please provide with APP_TABLE_NAME"
    exit 1
fi

if [[ ! "$APP_S3_PREFIX" ]]; then
    printf "\n ** Please provide with APP_S3_PREFIX"
    exit 1
fi

if [[ ! "$APP_S3_REGION" ]]; then
    printf "\n ** Please provide with APP_S3_REGION"
    exit 1
fi

if [[ ! "$APP_DB_REGION" ]]; then
    printf "\n ** Please provide with APP_DB_REGION"
    exit 1
fi

# Run backup
node_modules/.bin/gulp backup-full \
    --s3bucket ${APP_S3_BUCKET} \
    --s3prefix ${APP_S3_PREFIX} \
    --s3region ${APP_S3_REGION} \
    --dbtable ${APP_TABLE_NAME} \
    --dbregion ${APP_DB_REGION}

# Capture success/error status and write status file
RV=$?
STATUS_FILE=/tmp/dynamodb_backup_status.$$
if [ "${RV}" -eq "0" ]; then
  echo "OK" > ${STATUS_FILE}
else
  echo "BAD" > ${STATUS_FILE}
fi
aws s3 cp ${STATUS_FILE} s3://${APP_S3_BUCKET}/status/${APP_TABLE_NAME}/status

exit $RV
snakelab commented 7 years ago

Thanks for quick reply. As far as i see the code there should not be a problem using it with a lambda function working on a smaller amount of data...