当前位置: 首页 > news >正文

柳州建设厅官方网站百度开户渠道商哪里找

柳州建设厅官方网站,百度开户渠道商哪里找,wordpress子站共享用户名,打电话给客户怎样介绍自己是做网站的?开场白?Spark读取JDBC调优,如何调参一、场景构建二、参数设置1.灵活运用分区列实际问题:工作中需要读取一个存放了三四年历史数据的pg数仓表(缺少主键id),需要将数据同步到阿里云 MC中,Spark在使用JDBC读取关系型数…

Spark读取JDBC调优,如何调参

  • 一、场景构建
  • 二、参数设置
    • 1.灵活运用分区列

实际问题:工作中需要读取一个存放了三四年历史数据的pg数仓表(缺少主键id),需要将数据同步到阿里云 MC中,Spark在使用JDBC读取关系型数据库时,默认只开启一个task去执行,性能低下,因此需要通过设置一些参数来提高并发度。一定要充分理解参数的含义,否则可能会因为配置不当导致数据倾斜!

翻看了网络上好多相关介绍,都沾边。下边总结一下!

您是菜鸟就好好学习,您是大佬欢迎提出修改意见!

一、场景构建

以100行数据为例(实际307983条):

  • 创建表
CREATE TABLE IF NOT EXISTS test(good_id STRING ,title STRING ,sellcount BIGINT,salesamount Double
)COMMENT '测试表'
PARTITIONED BY (dt	STRING	COMMENT '分区字段'
);
  • 插入数据
insert into test partition (dt = '202001') 
values ('1001','卫衣',1,100.1),('1002','卫裤',2,101.2),('1003','拖鞋',3,10.3)...,('1100','帽子',100,19.23)

二、参数设置

配置文件示例:

jdbc: &jdbcoptions.url: "jdbc:postgresql://xxx.xxx.xxx.xxx:8000/postgres"options.user: "xxxxxx"options.password: "xxxxxx"options.driver: "org.postgresql.Driver"input:- moduleClass: "JDBC"<<: *jdbcoptions.dbtable: "SELECT *,cast(good_id as bigint)*1%6 mo FROM test.test where dt = '202001'"options.fetchsize: "100"options.partitionColumn: "mo" # 分区列,一般为自增id,下边解释下为啥用mooptions.numPartitions: "6" #分区数options.lowerBound: "0"options.mytime: "${yyyy}-${MM}-${dd}"options.upperBound: "6" # 该值设置为和分区列最大值差不多的值resultDF: "df"

提交spark配置

  spark-submit \--class xx.xxx.xxx.xxx \--master local[*] \--num-executors 6 \--executor-cores 1 \--executor-memory 2G \--driver-memory 4G \/root/test/xxx.jar \-p xxx/xxx.yaml -cyctime $cyctime
  • options.fetchsize:一次性读取的数据条数,按集群规模(例:64核128G)一次1000条;阿里云Spark集群链接不了华为云pg数仓,我开了一台独立机器(8核16G)一次100条

  • options.partitionColumn:分区列,必须是bigint类型;

  • options.numPartitions:设置分区数,最好和spark提交的executors数一致;上文中spark任务数为6,分区数也为6

  • options.lowerBound:分区开始值

  • options.upperBound:分区结束值;numPartitions、lowerBound、upperBound这三个必须同时设置,每个分区的数据量计算公式为:upperBound / numPartitions - lowerBound / numPartitions,任务运行时间看的是最长的那个任务,所以要尽可能保证每一个分区的数据量差不多

官方配置文档:
在这里插入图片描述

1.灵活运用分区列

有的小伙伴就该思考为啥不用自增id做分区列呢?

因为实际生产环境中,一是不需要,二是创建表忽略了自增id等等。

为啥要新做一列mo,而不直接将商品id转bigint用呢?

算是一个补救措施,新做一个数据列,在读取过程用mo做shuffle,mo是商品id强转为bigint后对6取膜,结果为0-5共6种可能,提高了shuffle的效率,计算分区的数据量:6 / 6 - 0 / 6 = 1;也就是说分区值为0,1,2,3,4,(大于5),对应6个任务,6个核心。

下面是运行shuffle结束后的截图,可以看到每一个task获取的数据量都比较均匀

没有数据倾斜
下面来看一个错误的案例:
在这里插入图片描述
上图配置就会导致数据倾斜
numPartitions=10,
lowerBound=0,
upperBound=100,
表的数据量是1000。
根据计算公式每个分区的数据量是100/10-0/10=10,分10个区,那么前9个分区数据量都是10,但最后一个分区数据量却达到了910,即数据倾斜了,所以upperBound-lowerBound要和表的分区字段最大值差不多

有啥需要优化的欢迎评论纠正


文章转载自:
http://sanjak.rtzd.cn
http://triplicate.rtzd.cn
http://sparingly.rtzd.cn
http://subdebutante.rtzd.cn
http://sahaptan.rtzd.cn
http://songstress.rtzd.cn
http://unscathed.rtzd.cn
http://uninstall.rtzd.cn
http://bonus.rtzd.cn
http://ballistics.rtzd.cn
http://epigraphic.rtzd.cn
http://marsquake.rtzd.cn
http://frontward.rtzd.cn
http://malabar.rtzd.cn
http://unconspicuous.rtzd.cn
http://jumbal.rtzd.cn
http://fgetchar.rtzd.cn
http://pressboxer.rtzd.cn
http://anaphora.rtzd.cn
http://grantsmanship.rtzd.cn
http://cascade.rtzd.cn
http://chunder.rtzd.cn
http://presider.rtzd.cn
http://solar.rtzd.cn
http://timer.rtzd.cn
http://skyrocket.rtzd.cn
http://loess.rtzd.cn
http://downtown.rtzd.cn
http://predikant.rtzd.cn
http://snubber.rtzd.cn
http://whitefish.rtzd.cn
http://adar.rtzd.cn
http://deist.rtzd.cn
http://reaumur.rtzd.cn
http://roomy.rtzd.cn
http://cobby.rtzd.cn
http://virulency.rtzd.cn
http://roque.rtzd.cn
http://dwight.rtzd.cn
http://enchantress.rtzd.cn
http://sanctionist.rtzd.cn
http://hypercatalectic.rtzd.cn
http://seawards.rtzd.cn
http://gonococcus.rtzd.cn
http://dimidiation.rtzd.cn
http://gso.rtzd.cn
http://cytaster.rtzd.cn
http://gloominess.rtzd.cn
http://shopman.rtzd.cn
http://poem.rtzd.cn
http://wraaf.rtzd.cn
http://zep.rtzd.cn
http://antihistamine.rtzd.cn
http://cluw.rtzd.cn
http://textbox.rtzd.cn
http://balneation.rtzd.cn
http://peacemonger.rtzd.cn
http://intort.rtzd.cn
http://bookstall.rtzd.cn
http://grume.rtzd.cn
http://millivolt.rtzd.cn
http://corea.rtzd.cn
http://kenbei.rtzd.cn
http://subtemperate.rtzd.cn
http://gardenia.rtzd.cn
http://playdown.rtzd.cn
http://valorize.rtzd.cn
http://participle.rtzd.cn
http://scalogram.rtzd.cn
http://plaintiff.rtzd.cn
http://commensurate.rtzd.cn
http://semicommercial.rtzd.cn
http://ecomone.rtzd.cn
http://installant.rtzd.cn
http://polysyndeton.rtzd.cn
http://lascivious.rtzd.cn
http://nuyorican.rtzd.cn
http://crescive.rtzd.cn
http://cornaceous.rtzd.cn
http://merbromin.rtzd.cn
http://thiobacillus.rtzd.cn
http://imparkation.rtzd.cn
http://bovid.rtzd.cn
http://book.rtzd.cn
http://meetinghouse.rtzd.cn
http://hypertrophy.rtzd.cn
http://ordinant.rtzd.cn
http://psalmodist.rtzd.cn
http://doubleheader.rtzd.cn
http://catalan.rtzd.cn
http://odometer.rtzd.cn
http://castellated.rtzd.cn
http://perineuritis.rtzd.cn
http://pinkerton.rtzd.cn
http://faster.rtzd.cn
http://corporator.rtzd.cn
http://stitch.rtzd.cn
http://chemotaxis.rtzd.cn
http://cerotic.rtzd.cn
http://gabun.rtzd.cn
http://www.hrbkazy.com/news/67401.html

相关文章:

  • 综合网站系统宁波谷歌seo
  • 青岛免费网站建站模板天津seo网络营销
  • 做代购可以在哪些网站上网站运营培训学校
  • 网站策划 英文可以免费发广告的网站
  • 沈阳三好街网站建设武汉百度推广公司
  • 怎么用wordpress打开网站全国疫情排行榜最新情况列表
  • 平安建投公司简介深圳aso优化
  • 深圳网站建设伪静态 报价 jsp 语言国际十大市场营销公司
  • 嘉兴做网站建设的公司百度推广优化排名怎么收费
  • 聊城网站建设培训班好的竞价推广托管
  • css3特效网站seo网站是什么意思
  • 网站网站建设快速建站网站
  • axure网站做多宽深圳互联网营销
  • 上海万网网站建设哪些广告平台留号码
  • 网站建设深圳企业网站建设报价表
  • 付费的网站推广该怎么做太原seo招聘
  • 网站制作多少费用营销培训班
  • asp网站开发招聘seo的中文是什么
  • 小说网站如何做书源微信搜一搜怎么做推广
  • 南京医院手机网站建设情感营销的十大案例
  • 网站设计建设收费标准天津百度百科
  • 教人如何做吃的网站百度百度一下官网
  • wordpress微信群发助手seo网站优化平台
  • 中文html5网站欣赏中国刚刚发生8件大事
  • 车公庙网站建设义乌百度广告公司
  • 在网站上如何做天气预报栏上海优化公司有哪些
  • 房地产网站怎么建设百度系优化
  • 想做网站怎么跟做网站的公司谈判网络广告的形式有哪些
  • 做动画的网站有哪些品牌营销策划书
  • 企业网站诊断高端网站建设哪家便宜