简体   繁体   中英

Microservice for running cron job in spring boot application

Application design question here: I have a spring boot application and I am tasked with designing a cron job that will run every 1 hour, collect some data from our RDS database and send it to a shared redshift instance. Redshift instance is used by the mode analytics tool to extract some data and run some reports for the concerned people.
Question is: should I be writing a new microservice just for this job? We don't want this to be a part of our application anymore because this task is kind of heavy and irrelevant to the actual application. But if I write a service for this it will be sitting idle when cron job is not running and wasting resources. Is lambda better for this?

If you are hosted on AWS , it's definitely a better alternative to run it in the serverless environment with [scheduled] job. This will significantly reduce your AWS bill and save your company money. If you need to just dump those reports, use S3. In case you need intensive IOPS and/or availability among multiple availability zones then use EFS. ( https://docs.aws.amazon.com/lambda/latest/dg/services-cloudwatchevents-expressions.html ).

Just create the lambda and schedule it with CloudWatch every hour . 云观察流

If you host Kubernetes , you can also create CronJob.

apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: hello
spec:
  schedule: "*/1 * * * *"
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: hello
            image: busybox
            args:
            - /bin/sh
            - -c
            - date; echo Hello from the Kubernetes cluster
          restartPolicy: OnFailure

Source: k8s docs

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM