JindoRuntime is a C++-based execution engine that supports dataset management and caching for OSS. By orchestrating JindoRuntime, Fluid provides dataset observability, auto scaling, and data migration. This guide shows how to use Fluid with ACS compute power to accelerate data access.
Prerequisites
-
You have activated Object Storage Service (OSS). For more information, see Activate OSS.
-
You have installed the ack-fluid component, version 1.0.11-* or later. For more information, see Use Helm to manage ACS applications.
-
You have enabled privileged mode for ACS pods.
NoteUsing Fluid to accelerate data access requires privileged mode. To enable this mode, submit a ticket.
Procedure
Step 1: Prepare data in an OSS bucket
-
Run the following command to download the test data.
wget https://archive.apache.org/dist/spark/spark-3.0.1/spark-3.0.1-bin-hadoop2.7.tgz -
Upload the downloaded test data to a bucket in OSS.
ImportantThis example uses an ECS instance running Alibaba Cloud Linux 3.2104 LTS 64-bit to show how to upload data to OSS. For instructions on other operating systems, see ossutil quick start and ossutil 1.0.
-
Run the following command to create a bucket named
examplebucket.NoteIf the command returns
ErrorCode=BucketAlreadyExists, the bucket name is already in use. Because bucket names must be globally unique in OSS, replaceexamplebucketwith a unique name.ossutil64 mb oss://examplebucketExpected output:
0.668238(s) elapsedThis output confirms the creation of the bucket named
examplebucket. -
Upload the downloaded test data to the
examplebucketbucket.ossutil64 cp spark-3.0.1-bin-hadoop2.7.tgz oss://examplebucket -
(Optional) Configure access permissions for the bucket and its data. For more information, see Overview of access control.
-
Create a file named
mySecret.yamlwith the following content.apiVersion: v1 kind: Secret metadata: name: mysecret stringData: fs.oss.accessKeyId: xxx fs.oss.accessKeySecret: xxxThe
fs.oss.accessKeyIdandfs.oss.accessKeySecretparameters specify theAccessKey IDandAccessKey Secretused to access OSS. -
Run the following command to create the secret. Kubernetes automatically encodes the created secret to prevent it from being exposed as plaintext.
kubectl create -f mySecret.yaml
Step 2: Create a dataset and a JindoRuntime
-
Create a
resource.yamlfile with the following content:-
A dataset that describes the remote dataset and the underlying file system (UFS).
-
A JindoRuntime that starts a JindoFS cluster to provide caching services.
NoteYou can run the
kubectl get pods --field-selector=status.phase=Running -n fluid-systemcommand to check if the dataset-controller and jindoruntime-controller in the ack-fluid component are running correctly.This example primarily uses CPU compute power. To accelerate the loading of Large Language Model (LLM) services, ensure the zone you select when creating the cluster supports GPU resources. For more information, see GPU-accelerated compute instance types.
The following table describes the parameters.
Parameter
Description
mountPoint
oss://<oss_bucket> specifies the mount path of the UFS. <oss_bucket> is the name of your OSS bucket. For example:
oss://examplebucket.fs.oss.endpoint
The endpoint of the OSS bucket. Both public and internal endpoints are supported. For example:
oss-cn-beijing-internal.aliyuncs.com. For more information, see OSS regions and endpoints.replicas
The number of worker replicas in the JindoFS cluster.
mediumtype
The type of cache medium. JindoFS currently supports only one of the following cache types:
HDD,SSD, orMEM.path
The storage path. Only a single path is supported. When
MEMis the cache type, you must specify a local path to store files such as logs.quota
The maximum cache capacity, in GiB.
high
The high watermark for storage usage.
low
The low watermark for storage usage.
-
-
Create the JindoRuntime and dataset.
kubectl create -f resource.yaml -
Check the deployment status of the JindoRuntime and dataset.
-
Check the deployment status of the dataset.
kubectl get dataset hadoopExpected output:
NAME UFS TOTAL SIZE CACHED CACHE CAPACITY CACHED PERCENTAGE PHASE AGE hadoop 209.74MiB 0.00B 4.00GiB 0.0% Bound 56s -
Check the deployment status of the JindoRuntime.
kubectl get jindoruntime hadoopExpected output:
NAME MASTER PHASE WORKER PHASE FUSE PHASE AGE hadoop Ready Ready Ready 2m11sThe output shows that the dataset and JindoRuntime are ready.
-
-
Run the following command to check the creation status of the persistent volume (PV) and persistent volume claim (PVC). Fluid names the PVC after the dataset.
kubectl get pv,pvcExpected output:
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS VOLUMEATTRIBUTESCLASS REASON AGE persistentvolume/default-hadoop 100Pi ROX Retain Bound default/hadoop fluid <unset> 2m5s NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS VOLUMEATTRIBUTESCLASS AGE persistentvolumeclaim/hadoop Bound default-hadoop 100Pi ROX fluid <unset> 2m5s
Step 3: Preload the dataset
To significantly improve data loading speed and ensure data processing logic is correct, you need to preload the dataset.
-
If the data in OSS does not change, create a
dataload.yamlfile with the following content to perform a one-time data preload.apiVersion: data.fluid.io/v1alpha1 kind: DataLoad metadata: name: hadoop spec: dataset: name: hadoop namespace: default loadMetadata: true -
If the data in OSS is updated dynamically, configure periodic data preloading. For more information, see Scenario 2: Read-only data with periodic updates in backend storage.
-
Create the DataLoad resource to perform the one-time preload.
kubectl create -f dataload.yaml -
Check the data preloading status.
kubectl get dataloadExpected output:
NAME DATASET PHASE AGE DURATION hadoop hadoop Complete 92m 51s
Step 4: Create a pod to test acceleration
You can test the JindoFS acceleration service by creating an application pod or submitting a machine learning job. The following example creates a pod that accesses the same data multiple times. By comparing the access times, you can observe the acceleration provided by JindoRuntime.
-
Create a file named app.yaml with the following content.
apiVersion: v1 kind: Pod metadata: name: demo-app labels: # Mounting on ACS requires sidecar injection by the Fluid webhook. Add the following label. alibabacloud.com/fluid-sidecar-target: acs spec: containers: - name: demo image: mirrors-ssl.aliyuncs.com/nginx:latest volumeMounts: - mountPath: /data name: hadoop resources: requests: cpu: 14 memory: 56Gi volumes: - name: hadoop persistentVolumeClaim: ## The name of the Fluid dataset. claimName: hadoop nodeSelector: type: virtual-kubelet tolerations: - key: virtual-kubelet.io/provider operator: Equal value: alibabacloud effect: NoSchedule -
Run the following command to create the application pod.
kubectl create -f app.yaml -
Test the file copy speed without JindoFS cache acceleration.
-
Check the size of the test file.
kubectl exec -it demo-app -c demo -- du -sh /data/spark-3.0.1-bin-hadoop2.7.tgzExpected output:
210M /data/spark-3.0.1-bin-hadoop2.7.tgz -
Check the time it takes to copy the file.
time cp /data/spark-3.0.1-bin-hadoop2.7.tgz /dev/nullExpected output:
real 0m1.883s user 0m0.001s sys 0m0.041sThe file copy took 1.883 seconds.
-
-
Check the cache status of the dataset.
kubectl get dataset hadoopExpected output:
NAME UFS TOTAL SIZE CACHED CACHE CAPACITY CACHED PERCENTAGE PHASE AGE hadoop 209.74MiB 209.74MiB 4.00GiB 100.0% Bound 64mThe output shows that
100.0%of the data is now cached in JindoFS. -
Delete the sample application pod and check the file copy time again.
NoteThe application pod is deleted to prevent other factors, such as the page cache, from affecting the test results. If a local cache already exists in the pod, the copy operation uses it by default.
Run the following commands to check the file copy time.
kubectl exec -it demo-app -c demo -- bash time cp /data/spark-3.0.1-bin-hadoop2.7.tgz /dev/nullExpected output:
real 0m0.203s user 0m0.000s sys 0m0.047sThe copy operation now takes 0.203 seconds, roughly 9 times faster than the first attempt. This speed increase occurs because JindoFS serves the file from its cache.
ImportantThe copy times provided in this topic are for reference only. Actual results may vary depending on your environment.
Scenario: ACS compute power for ACK Pro clusters
This guide demonstrated how to use JindoFS to accelerate file copying with ACS compute power. You can apply the same steps when using ACS compute power in an ACK Pro cluster. For more information about using ACS compute power in an ACK Pro cluster, see Use ACS compute power in an ACK Pro cluster.
To follow this guide in an ACK Pro cluster, make the following adjustments:
-
The ack-fluid component must also be installed in the ACK Pro cluster. For more information, see Use Helm to simplify application deployment.
-
Use the following configuration to create the dataset and JindoRuntime.
apiVersion: data.fluid.io/v1alpha1 kind: Dataset metadata: name: hadoop spec: mounts: ## To specify a subdirectory, use the format oss://<oss_bucket>/{oss_path}. - mountPoint: oss://<oss_bucket> # Replace <oss_bucket> with your bucket name. options: fs.oss.endpoint: <oss_endpoint> # Replace <oss_endpoint> with your OSS endpoint. name: hadoop path: "/" encryptOptions: - name: fs.oss.accessKeyId valueFrom: secretKeyRef: name: mysecret key: fs.oss.accessKeyId - name: fs.oss.accessKeySecret valueFrom: secretKeyRef: name: mysecret key: fs.oss.accessKeySecret --- apiVersion: data.fluid.io/v1alpha1 kind: JindoRuntime metadata: name: hadoop spec: ## Adjust as needed. replicas: 4 tieredstore: levels: - mediumtype: MEM path: /dev/shm volumeType: emptyDir quota: 48Gi high: "0.99" low: "0.95"Key differences for ACK Pro clusters:
-
ACS uses virtual nodes, which scale differently than nodes in an ACK Pro cluster. Therefore, the ACS configuration requires
.spec.placement: Sharedandnetworkmode. -
Fluid workers require a high-bandwidth environment. With ACS, you must specify high-spec resources to ensure sufficient bandwidth. For example, the ACS configuration in this guide specified
compute-class: performanceand configured theresourcessection to ensure the pods had enough bandwidth.
-