spark 在并行任务上只使用一个核心
spark using only one core on parallelism task
所以我有这个代码:
conf = SparkConf().setAll((
("spark.python.profile", "true" if args.profile else "false"),
("spark.task.maxFailures", "20"),
("spark.driver.cores", "4"),
("spark.executor.cores", "4"),
("spark.shuffle.service.enabled", "true"),
("spark.dynamicAllocation.enabled", "true"),
))
# TODO could this be set somewhere in cosr-ops instead?
executor_environment = {}
if config["ENV"] == "prod":
executor_environment = {
"PYTHONPATH": "/cosr/back",
"PYSPARK_PYTHON": "/cosr/back/venv/bin/python",
"LD_LIBRARY_PATH": "/usr/local/lib"
}
sc = SparkContext(appName="Common Search Index", conf=conf, environment=executor_environment)
# First, generate a list of all WARC files
warc_filenames = list_warc_filenames()
# Then split their indexing in Spark workers
warc_records = sc.parallelize(warc_filenames, 4).flatMap(iter_records)
虽然它发射了所有的 spark 东西,但它使用了所有的核心。
但是当它开始执行任务(索引)时,它只使用 1 个核心就 100%。
如何让一个spark任务使用所有的核心?
问题出在 python 本身没有使用所有核心。我实现了多线程。
感谢所有帮助过的人。
所以我有这个代码:
conf = SparkConf().setAll((
("spark.python.profile", "true" if args.profile else "false"),
("spark.task.maxFailures", "20"),
("spark.driver.cores", "4"),
("spark.executor.cores", "4"),
("spark.shuffle.service.enabled", "true"),
("spark.dynamicAllocation.enabled", "true"),
))
# TODO could this be set somewhere in cosr-ops instead?
executor_environment = {}
if config["ENV"] == "prod":
executor_environment = {
"PYTHONPATH": "/cosr/back",
"PYSPARK_PYTHON": "/cosr/back/venv/bin/python",
"LD_LIBRARY_PATH": "/usr/local/lib"
}
sc = SparkContext(appName="Common Search Index", conf=conf, environment=executor_environment)
# First, generate a list of all WARC files
warc_filenames = list_warc_filenames()
# Then split their indexing in Spark workers
warc_records = sc.parallelize(warc_filenames, 4).flatMap(iter_records)
虽然它发射了所有的 spark 东西,但它使用了所有的核心。
但是当它开始执行任务(索引)时,它只使用 1 个核心就 100%。
如何让一个spark任务使用所有的核心?
问题出在 python 本身没有使用所有核心。我实现了多线程。
感谢所有帮助过的人。