简体   繁体   English

在 Apache Flink 中开发和部署作业

[英]Developing and deploy jobs in Apache Flink

we started to develop some jobs with Flink.我们开始用 Flink 开发一些工作。 Our current dev / deployment process looked like this: 1. develop code in local IDE and compile 2. upload jar-file to server (via UI) 3. register new job我们当前的开发/部署过程如下所示: 1. 在本地 IDE 中开发代码并编译 2. 将 jar 文件上传到服务器(通过 UI) 3. 注册新作业

However it turns out that the generate jar-file is ~70MB and upload process takes a few minutes.然而事实证明,生成的 jar 文件大约为 70MB,上传过程需要几分钟。 What is the best way to speed up development (eg using a on-server ide?)加快开发速度的最佳方法是什么(例如,使用服务器上的 ide?)

One solution is to use a version control system and after committing and pushing your changes, you might build the jar on the server itself.一种解决方案是使用版本控制系统,在提交和推送更改后,您可以在服务器本身上构建 jar。 You could write a simple script for this.您可以为此编写一个简单的脚本。

The other solution, which would take time and effort is to set up a CI CD Pipeline which would automate the entire process and much manual effort would be minimised.另一种需要时间和精力的解决方案是建立一个CI CD 管道,该管道将自动化整个过程,并最大限度地减少手动工作。

Also, try not to use fat jar to minimise the jar size if you have to scp your jar to the cluster.此外,如果您必须将 jar scp 到集群,请尽量不要使用 fat jar来最小化 jar 大小。

First off, uploading 70 mb shouldn't take minutes nowadays.首先,现在上传 70 mb 不应该花几分钟。 You might want to check your network configurations.您可能需要检查您的网络配置。 Of course, if your internet connection is not good, you can't help it.当然,如果您的互联网连接不好,您也无能为力。

In general, I'd try to avoid cluster test runs as much as possible.一般来说,我会尽量避免集群测试运行。 It's slow and hard to debug.调试缓慢且困难。 It should only ever be used for performance tests or right before releasing into production.它应该只用于性能测试或在发布到生产之前。

All logic should be unit tested.所有逻辑都应该进行单元测试。 The complete job should be integration tested and ideally you'd also have an end-to-end test.完整的工作应该经过集成测试,理想情况下,您还应该进行端到端测试。 I recommend to use a docker-based approach for external systems and use things like test containers for Kafka, such that you are able to run all tests from your IDE.我建议对外部系统使用基于 docker 的方法,并使用诸如 Kafka 的测试容器之类的东西,这样您就可以从 IDE 运行所有测试。

Going onto the test cluster should then be a rare thing.进入测试集群应该是一件罕见的事情。 If you find any issue that has not been covered by your automatic tests, you need to add a new test case and solve it locally, such that there is a high probability that it will be solved on the test cluster.如果你发现任何你的自动测试没有覆盖的问题,你需要添加一个新的测试用例并在本地解决它,这样它就很有可能在测试集群上解决。

edit (addressing comment):编辑(地址评论):

If it's much easier for you to write a Flink job to generate data, then it sounds like a viable option.如果您编写 Flink 作业来生成数据要容易得多,那么这听起来像是一个可行的选择。 I'm just fearing that you would also need to test that job...我只是担心你还需要测试那份工作......

It rather sounds like you want to have an end-2-end setup where you run several Flink jobs in succession and compare the final results.听起来更像是您想要一个端到端的设置,您可以连续运行多个 Flink 作业并比较最终结果。 That's a common setup for complex pipelines consisting of several Flink jobs.这是由多个 Flink 作业组成的复杂管道的常见设置。 However, it's rather hard to maintain and may have unclear ownership status if it involves components from several teams.但是,如果涉及多个团队的组件,则维护起来相当困难,并且可能所有权状态不明确。 I like to rather solve it by having tons of metrics (how many records are produced, how many invalid records are filtered in each pipeline...) and having specific validation jobs that just assess the quality of (intermediate) output (potentially involving humans).我更喜欢通过拥有大量指标(产生了多少记录,在每个管道中过滤了多少无效记录......)并拥有仅评估(中间)输出质量的特定验证作业(可能涉及人类)来解决它)。

So from my experience, either you can test the logic in some local job setup or it's so big that you spend much more time in setting and maintaining the test setup than actually writing production code.所以根据我的经验,要么你可以在一些本地作业设置中测试逻辑,要么它太大了,你花在设置和维护测试设置上的时间比实际编写生产代码要多得多。 In the latter case, I'd rather trust and invest in the monitoring and quality assurance capabilities of (pre-)production that you need to have anyways.在后一种情况下,我宁愿相信并投资于您无论如何都需要的(预)生产的监控和质量保证能力。

If you really just want to test one Flink job with another, you can also run the Flink job in testcontainers, so technically it's not an alternative but an addition.如果你真的只是想用另一个测试一个 Flink 作业,你也可以在 testcontainers 中运行 Flink 作业,所以从技术上讲,这不是替代方案,而是一个补充。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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