尽管进行了分区,但我一直在炸毁 spark 集群
despite partitioning I keep blowing up the spark cluster
我有一个 spark 作业,它以两种方式之一破坏我们的 CDH 集群,具体取决于我如何分区。此作业的目的是生成 1 到 210,094,780,875 组四个整数之间的任意值。作业正在通过 spark-submit 提交,master 设置为 YARN。下面是与这个问题密切相关的代码片段:
// build rdd and let cluster build up the ngram list
val streamList_rdd = sc.parallelize(streamList).repartition(partitionCount)
val rdd_results = streamList_rdd.flatMap { x => x.toList }
println(rdd_results.count())
streamList 是一个生成器列表,这些生成器已使用 floor/ceiling 值(包含两个 Int 的元组)播种,将生成由 floor/ceiling。这个想法是将整个集群的发电工作外包出去,这就是前端脱落的地方。如果 partitionCount 太低(因此每个分区的大小都很大),worker 会因内存不足而崩溃。如果 partitionCount 很高(因此从内存的角度来看每个分区的大小是可管理的),您会开始看到如下错误:
java.io.IOException: Connection reset by peer
at sun.nio.ch.FileDispatcherImpl.read0(Native Method)
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39)
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223)
at sun.nio.ch.IOUtil.read(IOUtil.java:192)
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:379)
at io.netty.buffer.PooledUnsafeDirectByteBuf.setBytes(PooledUnsafeDirectByteBuf.java:313)
at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:881)
at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:242)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:119)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
at io.netty.util.concurrent.SingleThreadEventExecutor.run(SingleThreadEventExecutor.java:111)
at java.lang.Thread.run(Thread.java:745)
我理解的内存问题 - 我不理解的是为什么存在高分区数(~100k 或更多)的问题。有没有办法让我在保留 YARN 在管理集群资源方面的作用的同时完成这项工作?
鉴于数据量大,内存错误的存在,我认为你需要分配更多的集群资源。
增加分区可以提高并行性,但代价是在已经不够大的集群上消耗更多资源。我还怀疑重新分区操作会导致洗牌,这在最好的情况下是一项昂贵的操作,非常糟糕(灾难性的!)当你有足够的数据到内存不足时。但是没有日志,那是猜想。
心跳失败的原因很可能是执行程序负载太重而未能及时响应,或者进程已崩溃/被 YARN 杀死...
我有一个 spark 作业,它以两种方式之一破坏我们的 CDH 集群,具体取决于我如何分区。此作业的目的是生成 1 到 210,094,780,875 组四个整数之间的任意值。作业正在通过 spark-submit 提交,master 设置为 YARN。下面是与这个问题密切相关的代码片段:
// build rdd and let cluster build up the ngram list
val streamList_rdd = sc.parallelize(streamList).repartition(partitionCount)
val rdd_results = streamList_rdd.flatMap { x => x.toList }
println(rdd_results.count())
streamList 是一个生成器列表,这些生成器已使用 floor/ceiling 值(包含两个 Int 的元组)播种,将生成由 floor/ceiling。这个想法是将整个集群的发电工作外包出去,这就是前端脱落的地方。如果 partitionCount 太低(因此每个分区的大小都很大),worker 会因内存不足而崩溃。如果 partitionCount 很高(因此从内存的角度来看每个分区的大小是可管理的),您会开始看到如下错误:
java.io.IOException: Connection reset by peer
at sun.nio.ch.FileDispatcherImpl.read0(Native Method)
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39)
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223)
at sun.nio.ch.IOUtil.read(IOUtil.java:192)
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:379)
at io.netty.buffer.PooledUnsafeDirectByteBuf.setBytes(PooledUnsafeDirectByteBuf.java:313)
at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:881)
at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:242)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:119)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
at io.netty.util.concurrent.SingleThreadEventExecutor.run(SingleThreadEventExecutor.java:111)
at java.lang.Thread.run(Thread.java:745)
我理解的内存问题 - 我不理解的是为什么存在高分区数(~100k 或更多)的问题。有没有办法让我在保留 YARN 在管理集群资源方面的作用的同时完成这项工作?
鉴于数据量大,内存错误的存在,我认为你需要分配更多的集群资源。
增加分区可以提高并行性,但代价是在已经不够大的集群上消耗更多资源。我还怀疑重新分区操作会导致洗牌,这在最好的情况下是一项昂贵的操作,非常糟糕(灾难性的!)当你有足够的数据到内存不足时。但是没有日志,那是猜想。
心跳失败的原因很可能是执行程序负载太重而未能及时响应,或者进程已崩溃/被 YARN 杀死...