Code Monkey home page Code Monkey logo

Comments (4)

batCoder95 avatar batCoder95 commented on June 13, 2024 1

Hi @bbenzikry ,

Yes this definitely seems to be an issue because of the size of Glue catalog. I tried this with another Glue catalog in a different AWS region, with fewer databases and tables, and it works perfectly fine.

I'll see if I can come up with a solution for this and will definitely add a PR if I do.

Closing this issue. Cheers :)

from spark-eks.

bbenzikry avatar bbenzikry commented on June 13, 2024

Hi @BatCoder, do you set anything for spark.sql.catalogImplementation?
Also, in our case, we do not query the catalog tables directly - we simply use them to store metadata for delta lake use and update the catalog for downstream Athena access, so I haven't seen any performance degradation on our end.
Unfortunately I'm a bit busy this week, I'll only be able to really test things out on our staging environment at the end of next week.

Can you

  1. share your call / sql snippets and run the same job with logs set to TRACE log level?
  2. Share the logs from running without enableHiveSupport and send the same log message? is the memory allocation different in size?

from spark-eks.

batCoder95 avatar batCoder95 commented on June 13, 2024

Hi @bbenzikry ,

Yes I was initially trying without setting spark.sql.catalogImplementation, but it was still taking 15 minutes. Now I'm trying with setting this property to hive. But still the same performance.

I re-ran the job by setting the sparkSession's log level to "TRACE". On analyzing the debug logs, it seems to me that when we enable hive support, spark brings every single glue object (db, tables, views, UDFs) into the driver node memory. Not sure why this is happening in spite of setting spark.sql.catalogImplementation: hive. We have about 7k databases and over 20k tables in glue.

Below is the application yaml which I am using to deploy the spark application.

apiVersion: "sparkoperator.k8s.io/v1beta2"
kind: SparkApplication
metadata:
  name: testpyspark
  namespace: dev
spec:
  type: Python
  pythonVersion: "3"
  mode: cluster
  image: "<my image repository>"
  imagePullPolicy: Always
  mainApplicationFile: "s3a://spark-bucket/code/WithEnableHiveSupport.py"
  sparkVersion: "3.0.1"
  sparkConfigMap: spark-config-map
  sparkConf:
    "spark.hadoop.fs.s3.impl": "org.apache.hadoop.fs.s3a.S3AFileSystem"
    "spark.hadoop.fs.s3n.impl": "org.apache.hadoop.fs.s3a.S3AFileSystem"
    "spark.hadoop.fs.s3a.impl": "org.apache.hadoop.fs.s3a.S3AFileSystem"
    "spark.sql.catalogImplementation": "hive"
    "spark.hadoop.fs.s3a.aws.credentials.provider": "com.amazonaws.auth.WebIdentityTokenCredentialsProvider"
    "spark.kubernetes.authenticate.driver.serviceAccountName": "svc-spark-iam"
    "spark.eventLog.enabled": "true"
    "spark.eventLog.dir": "s3a://spark-bucket/events/"
  driver:
    cores: 1
    memory: 500m
    labels:
      version: 3.0.1
  executor:
    cores: 1
    instances: 1
    memory: 500m
    labels:
      version: 3.0.1

Below is the pySpark job code in which I observed this.

from pyspark.sql import SparkSession

spark = SparkSession.builder.appName("testpyspark").config("spark.sql.catalogImplementation", "hive").enableHiveSupport().getOrCreate()
spark.sparkContext.setLogLevel("TRACE")

# select from a very small table in glue
spark.sql("select * from my_glue_db.my_glue_table").show()

# writing a very small dataframe to s3
spark.range(1).write.format('csv').save("s3a://spark-bucket/csv/", mode="append")

print ("========================================================")
print ("Job Completed Successfully")
print ("========================================================")

spark.stop()

And below are the corresponding debug logs. Since, the full logs contain the actual glue object names and s3 path etc., which is business sensitive info, I won't be able to attach the full logs. This is the portion of the logs where spark is making GetGlueDatabase call in order to bring the db details into driver. This same call is being repeated for the entire catalog of glue objects.

2020-10-21 07:20:55,868 DEBUG auth.AWS4Signer: AWS4 Canonical Request: '"POST
/

amz-sdk-invocation-id:1b4d0910-ba86-8660-c020-dd59da370ea1
amz-sdk-request:ttl=20201021T072145Z;attempt=1;max=6
amz-sdk-retry:0/0/500
content-length:248
content-type:application/x-amz-json-1.1
host:glue.us-west-2.amazonaws.com
user-agent:aws-sdk-java/1.11.868 Linux/4.14.181-140.257.amzn2.x86_64 OpenJDK_64-Bit_Server_VM/25.265-b01 java/1.8.0_265 scala/2.12.10 vendor/Oracle_Corporation
x-amz-date:20201021T072055Z
x-amz-security-token: <security-token>
x-amz-target:AWSGlue.GetDatabases

amz-sdk-invocation-id;amz-sdk-request;amz-sdk-retry;content-length;content-type;host;user-agent;x-amz-date;x-amz-security-token;x-amz-target
5a84d973b42fca42e670e15da34c63b8a0267cfe1a92f4af203b10a7f2b1db7f"
2020-10-21 07:20:55,868 DEBUG auth.AWS4Signer: AWS4 String to Sign: '"AWS4-HMAC-SHA256
20201021T072055Z
20201021/us-west-2/glue/aws4_request
2404d72ab02b3145ed688f736fc62b179d5e3d558355a6eb8633eceee70d431c"
2020-10-21 07:20:55,868 DEBUG protocol.RequestAddCookies: CookieSpec selected: default
2020-10-21 07:20:55,868 DEBUG protocol.RequestAuthCache: Auth cache not set in the context
2020-10-21 07:20:55,868 DEBUG conn.PoolingHttpClientConnectionManager: Connection request: [route: {s}->https://glue.us-west-2.amazonaws.com:443][total kept alive: 1; route allocated: 1 of 50; total allocated: 1 of 50]
2020-10-21 07:20:55,868 DEBUG conn.PoolingHttpClientConnectionManager: Connection leased: [id: 3][route: {s}->https://glue.us-west-2.amazonaws.com:443][total kept alive: 0; route allocated: 1 of 50; total allocated: 1 of 50]
2020-10-21 07:20:55,868 DEBUG conn.DefaultManagedHttpClientConnection: http-outgoing-3: set socket timeout to 50000
2020-10-21 07:20:55,868 DEBUG conn.DefaultManagedHttpClientConnection: http-outgoing-3: set socket timeout to 50000
2020-10-21 07:20:55,868 DEBUG execchain.MainClientExec: Executing request POST / HTTP/1.1
2020-10-21 07:20:55,868 DEBUG execchain.MainClientExec: Proxy auth state: UNCHALLENGED
2020-10-21 07:20:55,869 DEBUG http.headers: http-outgoing-3 >> POST / HTTP/1.1
2020-10-21 07:20:55,869 DEBUG http.headers: http-outgoing-3 >> Host: glue.us-west-2.amazonaws.com
2020-10-21 07:20:55,869 DEBUG http.headers: http-outgoing-3 >> amz-sdk-invocation-id: 1b4d0910-ba86-8660-c020-dd59da370ea1
2020-10-21 07:20:55,869 DEBUG http.headers: http-outgoing-3 >> amz-sdk-request: ttl=20201021T072145Z;attempt=1;max=6
2020-10-21 07:20:55,869 DEBUG http.headers: http-outgoing-3 >> amz-sdk-retry: 0/0/500
2020-10-21 07:20:55,869 DEBUG http.headers: http-outgoing-3 >> Authorization: AWS4-HMAC-SHA256 Credential=ASIA6MH7QETQMPNZFJSL/20201021/us-west-2/glue/aws4_request, SignedHeaders=amz-sdk-invocation-id;amz-sdk-request;amz-sdk-retry;content-length;content-type;host;user-agent;x-amz-date;x-amz-security-token;x-amz-target, Signature=<signature>
2020-10-21 07:20:55,869 DEBUG http.headers: http-outgoing-3 >> Content-Type: application/x-amz-json-1.1
2020-10-21 07:20:55,869 DEBUG http.headers: http-outgoing-3 >> User-Agent: aws-sdk-java/1.11.868 Linux/4.14.181-140.257.amzn2.x86_64 OpenJDK_64-Bit_Server_VM/25.265-b01 java/1.8.0_265 scala/2.12.10 vendor/Oracle_Corporation
2020-10-21 07:20:55,869 DEBUG http.headers: http-outgoing-3 >> X-Amz-Date: 20201021T072055Z
2020-10-21 07:20:55,869 DEBUG http.headers: http-outgoing-3 >> X-Amz-Security-Token: <security-token>

P.S. I know you might be occupied with other work too, so there's no hurry in this. You can let me know whenever you get some time to look into this :)

from spark-eks.

bbenzikry avatar bbenzikry commented on June 13, 2024

Seems like you got to the root cause 👍
We don't have that many databases * tables so it makes sense we have not encountered it yet.
This is probably an issue with the calls made in the glue data catalog jar.
I'm actually using a fork for that to properly support spark 3 ( based on yet another fork ), so we may be able to fix this there.
If you come up with a solution before I get to check that out, I'll appreciate if you could add a PR here: https://github.com/bbenzikry/aws-glue-data-catalog-client-for-apache-hive-metastore

from spark-eks.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.