Long-running Cloud Run Jobs

  Рет қаралды 5,038

Google Cloud Tech

Google Cloud Tech

Күн бұрын

Cloud Run Jobs is a great way of running unattended workloads on a schedule, like data conversions or cleanups. And your jobs can now run for up to 24 hours. Follow along as Karolína Netolická and Martin Omander deploy a data import job and try out various options.
Chapters:
0:00 - Intro
1:11 - Deploy a job
1:53 - Schedule the job
2:22 - Parallelize the job
3:02 - Recap
Checkout more episodes of Serverless Expeditions → goo.gle/ServerlessExpeditions​
Subscribe to Google Cloud Tech → goo.gle/GoogleCloudTech
#ServerlessExpeditions

Пікірлер: 47
@googlecloudtech
@googlecloudtech 9 ай бұрын
🔔 Subscribe so you never miss an episode of Serverless Expeditions! → goo.gle/GoogleCloudTech
@banzai316
@banzai316 9 ай бұрын
Cool! I’m glad I found this channel. ❤️👏
@scorpdevnull
@scorpdevnull 9 ай бұрын
WoW, that's fantastic. I was waiting for the looooong time!!!!
@zhalie12345
@zhalie12345 9 ай бұрын
Awesome video GCT Team!!! Really like this type of video that simple and straightforward. Keep it up 👍👍
@TheMomander
@TheMomander 9 ай бұрын
Thank you!
@davidspiess2047
@davidspiess2047 9 ай бұрын
I would like to trigger a long running sync job by clicking a button on the frontend. Would it be possible to create and execute a cloud run job from my API and pass the job some parameters?
@TheMomander
@TheMomander 9 ай бұрын
Yes, you can trigger a job by calling the Cloud Run Jobs API from your code. If you run a web search for "execute google cloud run jobs" you will find the documentation. Click the "Client libraries" tab in the code example box and you will be guided to the library for your language of choice.
@dzivojelic
@dzivojelic Ай бұрын
Now we need a video how to build debug and run those jobs locally
@TheMomander
@TheMomander Ай бұрын
Thank you for that idea for another episode! In the meantime, let me share how I debug jobs locally. A Cloud Run Job is simply a code file that runs from top to bottom, so I run and debug it locally with my regular tools. For example, I run "node index.js" or "python main.py" on my local machine. If I need to interact with cloud databases or other APIs, I run "gcloud auth application-default login" before my debugging session. Hope this helps!
@SidneiBecker
@SidneiBecker 2 ай бұрын
Nice! I have a question.. Thinking about non-concurrent processing, like large database processing, which can't have two jobs running at the same time, is there a way in Google Cloud to have a queue of jobs, which executes my "new" job only when the "old" job finishes?
@TheMomander
@TheMomander 2 ай бұрын
You can start a job from application code using the client library. So one job could start another. Do a search for "execute cloud run jobs" and look for the "client libraries" section on that page. Best of luck!
@SidneiBecker
@SidneiBecker 2 ай бұрын
​@@TheMomander I'll be looking into that. Thanks!
@Melgazar9
@Melgazar9 7 ай бұрын
Hey I used cloud run for a long running ELT process, but the job kept getting killed after one hour. I read that cloud run has a max request limit of 1hr. Am i doing something wrong? Is there another service i should use? I only get a 60 minute request timeout.
@TheMomander
@TheMomander 7 ай бұрын
The default timeout is one hour. If you want a different timeout, use the "--task-timeout" parameter when you deploy your job. In the video we set a 24 hour timeout at timestamp 1:20.
@eklok5000
@eklok5000 9 ай бұрын
Cool Video! But why wouldn’t I use cloud function for that? Isn’t there a huge product Feature overlap? What’s the adv of using this
@TheMomander
@TheMomander 9 ай бұрын
Good question. You could definitely use a Cloud Function to run your unattended batch jobs. But by using Cloud Run Jobs, your jobs can run for up to 24 hours vs 60 minutes or 9 minutes for Cloud Functions (depending on the type of function). Cloud Run Jobs also lets you run many workers in parallel by setting the "tasks" parameter. Also, they don't expose an HTTP endpoint, which you may not want for a batch job.
@eklok5000
@eklok5000 9 ай бұрын
@@TheMomander that makes a lot of sense, thanks for clarifying!
@danielduhh
@danielduhh 9 ай бұрын
Fire
@vinoprime
@vinoprime 9 ай бұрын
Cool, I have a doubt, how to use containerized jobs? How to run a cloud run from a private docker image repository.
@TheMomander
@TheMomander 9 ай бұрын
In the video I deployed a job from source code. Google Cloud built a container for me in the background. If you prefer, you can build your own container and then deploy it as a Cloud Run Job. The container has to be stored in the private Artifact Registry in your Google Cloud project or in Docker Hub.
@mjad218
@mjad218 9 ай бұрын
Hi, I am part of Google Cloud for Startup. I rely heavily on Cloud Run and Cloud Run Jobs. The only thing I don't like is I can't deploy Cloud Run Jobs just like Cloud Run. Can you add Cloud Build triggers that can deploy to Cloud Run Jobs?
@TheMomander
@TheMomander 9 ай бұрын
Thank you for the suggestion! I will forward it to the team. I see people deploying their Cloud Run Jobs with Cloud Build's cloudbuild.yaml files or GitHub Actions. It's not quite point-and-click like it is for regular Cloud Run services, but it does give you automatic CI/CD once it's been set up. Best of luck with your startup!
@zhalie12345
@zhalie12345 9 ай бұрын
@@TheMomander Does deploying Cloud Run Jobs using Cloud Build is similar like deploying the Cloud Run?
@TheMomander
@TheMomander 9 ай бұрын
@@zhalie12345 Yes, that's exactly right. Do a web search for "create a new cloud run job" and you will see the different ways in which you can deploy new jobs.
@swapnilbodhe7501
@swapnilbodhe7501 9 ай бұрын
Query - if it's going to run for max 24 hours & parallel as well, what's the difference cloud run & dataflow. And in which scenario, would you use which service. Thank you
@TheMomander
@TheMomander 9 ай бұрын
I think your choice of Dataflow vs Cloud Run Jobs comes down to which programming model you are more comfortable with. If you prefer the Apache Beam style of data transformation, go with Dataflow. If you like to write your data transformations like you write regular scripts or web services, go with Cloud Run Jobs.
@swapnilbodhe7501
@swapnilbodhe7501 9 ай бұрын
@@TheMomander thanks for the reply, however, is this the only main difference to choose between cloud run or dataflow?
@TheMomander
@TheMomander 9 ай бұрын
@@swapnilbodhe7501 There are other differences too, but I don't know Dataflow enough to provide an authoritative list. If I were choosing between the two products, my top concern would which of the two programming paradigms my team was most familiar with.
@mohamedabdelkader9854
@mohamedabdelkader9854 3 ай бұрын
Hello can this job be triggered from applications with passed parameters ?
@TheMomander
@TheMomander 3 ай бұрын
Yes, you can execute Cloud Run Jobs from application code. Run a web search for "execute cloud run jobs" and you will find the documentation. The doc has a section titled "Override job configuration for a specific execution". Best of luck with your project!
@user-zg2nl3gh1o
@user-zg2nl3gh1o 6 ай бұрын
Can I make sure that only one instance of a job is running? I have a python script (it's a Telegram client), so in NO CIRCUMSTANCE i can allow two processes to be at the same time. Otherwise Telegram bans my Session ID, and I have to re-log and redeploy. That's what happened today when a trigger started a new execution while the old one was still running. Ideally, I want to have some number of retries (in case it fails), and a trigger in the morning, but so that the trigger would kill the previous execution. Is Cloud Run Jobs a good choice at all?
@TheMomander
@TheMomander 6 ай бұрын
I think the easiest way would be to set a timeout that is shorter than the schedule interval between starting the job. Depending on how the Telegram API works, you might also want to implement a graceful shutdown of your connection to their API right before your job terminates.
@user-zg2nl3gh1o
@user-zg2nl3gh1o 6 ай бұрын
​@@TheMomanderyeah... thanks, but I have come to the conclusion that Cloud Run is not suitable for this. And it started charging me about 2$/day, which is huge compared to Heroku. App Engine wasn't fun either. I even tried setting entrypoint "gunicorn --timeout 0" because otherwise it would restart every 30 seconds. Again, thanks for the answer.
@uhstube74
@uhstube74 2 ай бұрын
I have 2 questions based on my current understanding. Let me know if there is disconnect or reply on my query. 1)cloud run job is not on http protocol but cloud scheduler is able to invoke via http protocol using run.googleapi? 2)for cloud scheduler [attempt-deadline] param max value is 30 min for http. So for cloud run job which run more than 30 min ,cloud scheduler will treat as timeout & mark it as failed? What will happen to cloud run job process in this case?
@karolinanetolicka5982
@karolinanetolicka5982 2 ай бұрын
1) That's right - Cloud Scheduler can start a Cloud Run job by calling the Cloud Run API with the right project and job name. The easiest way to set this up is in the Cloud Run Cloud Console. 2) Cloud Scheduler only waits until the Cloud Run job STARTS running before it declares success. So you can start arbitrarily long Cloud Run jobs from Cloud Scheduler. The flip side of this, of course, is that if the Cloud Run jobs fails, Cloud Scheduler will have no idea about that.
@uhstube74
@uhstube74 2 ай бұрын
@karolinanetolicka5982 Thank you so much. So here cloud scheduler doesn't follow to know final status & only task is of it is kickoff the cloud run job
@karolinanetolicka5982
@karolinanetolicka5982 2 ай бұрын
@@uhstube74 That's correct. If you do need to track the final status, Cloud Workflows does that.
@user-dg8uc2yz4x
@user-dg8uc2yz4x 6 ай бұрын
Some questions i wish were addressed. What occurs if the schedule calls the job while its still running (assuming somehow the timeout is greater than the schedule occurrence). It would also be cool if you showed the logging in how it looks on a job running successfully vs not. How does the job pass in the index for parallel operations ? Is there a way to stop the schedule from triggering if the previous failed. Such as a pause ?
@TheMomander
@TheMomander 6 ай бұрын
You may enjoy the earlier video titled "Introducing Cloud Run Jobs". Some of your question are answered in that video. I will answer the remaining two here. If a schedule triggers a job while the previous execution of the job is still running, you'll have two jobs running in parallel. There is no built-in functionality for pausing the schedule in case of failures. Hope this helps!
@JZL003
@JZL003 9 ай бұрын
But for batch jobs, no preemtibility/spot is a huge cost hit, often for no reason. If you're doing big batches, repeating every few for such a huge cost savings is huge.
@TheMomander
@TheMomander 9 ай бұрын
I think it depends on the workload. One of my Cloud Run Jobs runs every midnight for an hour, at a cost of $0.07 per day. Because I used Cloud Run Jobs, it was really easy to write and deploy. Could I put in extra work and save some of that $0.07 per day? Probably. Is it worth my time? Probably not. As you stated, that equation changes if your volume changes. Once you start spending hundreds or thousands of dollars per month on your batch jobs, it may become worth it to spend more engineering hours on them.
@adoniskomplex91
@adoniskomplex91 9 ай бұрын
Would be nice to have long-running jobs for cloud run services, too.
@TheMomander
@TheMomander 9 ай бұрын
Thank you for the feedback; much appreciated!
@sandeepkulkarni4
@sandeepkulkarni4 9 ай бұрын
Would be great to see App engine covered in both of its types...standard and flexible.
@TheMomander
@TheMomander 9 ай бұрын
Thank you for the feedback, much appreciated!
@mohamedshafvan7844
@mohamedshafvan7844 9 ай бұрын
need more topics about multi=cluster management in k8s.
@TheMomander
@TheMomander 9 ай бұрын
Thank you for the suggestion. I focus on *serverless* topics. For Kubernetes videos, search KZfaq for my coworker's series called "Container Bytes".
Run your React app on Google Cloud
16:28
Google Cloud Tech
Рет қаралды 17 М.
DBT Core on Cloud Run Job
39:26
PracticalGCP
Рет қаралды 1,5 М.
Идеально повторил? Хотите вторую часть?
00:13
⚡️КАН АНДРЕЙ⚡️
Рет қаралды 8 МЛН
Опасность фирменной зарядки Apple
00:57
SuperCrastan
Рет қаралды 12 МЛН
UNO!
00:18
БРУНО
Рет қаралды 2,8 МЛН
Should you learn C++ in 2023?
8:06
Dreams of Code
Рет қаралды 54 М.
Final Cleanups: Just Minutes to a Shiny, Healthy Codebase!
21:38
Frankly Developing
Рет қаралды 657
AES: How to Design Secure Encryption
15:37
Spanning Tree
Рет қаралды 155 М.
What Can You Do with Python? - The 3 Main Applications
11:30
CS Dojo
Рет қаралды 3,5 МЛН
The cloud is over-engineered and overpriced (no music)
14:39
Tom Delalande
Рет қаралды 527 М.
Google Cloud CDN in a minute
2:45
Google Cloud Tech
Рет қаралды 7 М.
you will never ask about pointers again after watching this video
8:03
Low Level Learning
Рет қаралды 2,1 МЛН
Why Do Bubbles Form In Glasses Of Water?
12:33
Joe Scott
Рет қаралды 86 М.
Cloud Run QuickStart - Docker to Serverless
7:50
Fireship
Рет қаралды 182 М.
Yanlışlıkla Telefonumu Parçaladım!😱
0:18
Safak Novruz
Рет қаралды 671 М.
ноутбуки от 7.900 в тг laptopshoptop
0:14
Ноутбуковая лавка
Рет қаралды 3,5 МЛН
Это iPhone 16
0:52
Wylsacom
Рет қаралды 628 М.
Better Than Smart Phones☠️🤯 | #trollface
0:11
Not Sanu Moments
Рет қаралды 18 МЛН
Looks very comfortable. #leddisplay #ledscreen #ledwall #eagerled
0:19
LED Screen Factory-EagerLED
Рет қаралды 12 МЛН