# Baidu Object Storage

This guide describes how to configure [Baidu Object Storage (BOS)](https://cloud.baidu.com/doc/BOS/index.html) as Alluxio's under storage system. Baidu Object Storage (BOS) provides stable, secure, efficient and highly scalable storage services.

## Prerequisites

Before using BOS with Alluxio, follow the [BOS Process for Getting Started](https://intl.cloud.baidu.com/doc/BOS/s/Ik4xtp41n-en) to sign up for BOS and create a BOS bucket.

Before you get started, please ensure you have the required information listed below:

| `<BOS_BUCKET>`            | Create a new BOS bucket or use an existing bucket                                                                                                                                                                                                                                          |
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `<BOS_DIRECTORY>`         | The directory you want to use in the bucket, either by creating a new directory or using an existing one                                                                                                                                                                                   |
| `<BOS_ACCESS_KEY_ID>`     | <p>The <a href="https://intl.cloud.baidu.com/doc/Reference/s/jjwvz2e3p-en">Access Key ID</a> for BOS,<br>which are created and managed in the <a href="https://intl.cloud.baidu.com/doc/Reference/s/9jwvz2egb-en">BOS AccessKey management console</a></p>                                 |
| `<BOS_ACCESS_KEY_SECRET>` | <p>The <a href="https://intl.cloud.baidu.com/doc/Reference/s/jjwvz2e3p-en">Secret Access Key</a> for BOS,<br>which are created and managed in the <a href="https://intl.cloud.baidu.com/doc/Reference/s/9jwvz2egb-en">BOS AccessKey management console</a></p>                             |
| `<BOS_ENDPOINT>`          | <p>The internet endpoint of the bucket, which can be found in the bucket overview page with values like <code>bj.bcebos.com</code> and <code>gz.bcebos.com</code>.<br>Available endpoints are listed in the <a href="https://cloud.baidu.com/doc/BOS/s/akrqd2wcx">Region与Endpoint</a>.</p> |
| `<BOS_REGION>`            | <p>The region where the bucket is located, such as <code>cn-beijing</code> or <code>cn-guangzhou</code>.<br>Available regions are listed in the <a href="https://cloud.baidu.com/doc/BOS/s/akrqd2wcx">Region与Endpoint</a>.</p>                                                             |

## Basic Setup

For the general mount mechanism and `UnderFileSystem` CR field reference, see [Underlying Storage](/ee-ai-en/ai-3.8-15.1.x/ufs.md#basic-mount-setup).

{% tabs %}
{% tab title="Kubernetes (Operator)" %}
An example `ufs.yaml` to create a BOS mount point with the operator:

```yaml
apiVersion: k8s-operator.alluxio.com/v1
kind: UnderFileSystem
metadata:
  name: alluxio-bos
  namespace: alx-ns
spec:
  alluxioCluster: alluxio-cluster
  path: bos://<BOS_BUCKET>/<BOS_DIRECTORY>
  mountPath: /bos
  mountOptions:
    fs.bos.accessKeyId: <BOS_ACCESS_KEY>
    fs.bos.accessKeySecret: <BOS_ACCESS_KEY_SECRET>
    fs.bos.endpoint: <BOS_ENDPOINT>
```

{% endtab %}

{% tab title="Docker / Bare-Metal" %}
An example command to mount `bos://<BOS_BUCKET>/<BOS_DIRECTORY>` to `/bos` if not using the operator:

```shell
bin/alluxio mount add --path /bos/ --ufs-uri bos://<BOS_BUCKET>/<BOS_DIRECTORY> \
  --option fs.bos.accessKeyId=<BOS_ACCESS_KEY> --option fs.bos.accessKeySecret=<BOS_ACCESS_KEY_SECRET> \
  --option fs.bos.endpoint=<BOS_ENDPOINT>
```

Note that if you want to mount the root of the BOS bucket, add a trailing slash after the bucket name (e.g. `bos://BOS_BUCKET/`).
{% endtab %}
{% endtabs %}

## Advanced Setup

Note that configuration options can be specified as mount options or as configuration properties in `conf/alluxio-site.properties`.\
The following sections will describe how to set configurations as properties, but they can also be set as mount options via `--option <key>=<value>`.

### Enabling HTTPS

To enable the use of the HTTPS protocol for secure communication with BOS with an additional layer of security for data transfers, configure the following setting in conf/alluxio-site.properties:

```properties
fs.bos.endpoint=<BOS_ENDPOINT>
alluxio.underfs.bos.secure.http.enabled=true
```

### BOS multipart upload

We use multipart-upload method to upload one file by multiple parts, every part will be uploaded in one thread. It won't generate any temporary files while uploading.

There are other parameters you can specify in `conf/alluxio-site.properties` to potentially speed up the upload.

```properties
# Timeout for uploading part when using multipart upload.
alluxio.underfs.object.store.multipart.upload.timeout
```

```properties
# Thread pool size for BOS multipart upload.
alluxio.underfs.bos.multipart.upload.threads
```

```properties
# Multipart upload partition size for BOS. The default partition size is 64MB.
alluxio.underfs.bos.multipart.upload.part.size
```

Disable BOS multipart upload, the upload method uploads one file completely from start to end in one go. you need to modify `conf/alluxio-site.properties` to include:

```properties
alluxio.underfs.bos.multipart.upload.enabled=false
```

### Setting Request Retry Policy

For retry configuration that applies to all object store UFS types, see [Request Retry Policy](/ee-ai-en/ai-3.8-15.1.x/ufs.md#request-retry-policy) in the UFS overview.

### High Concurrency Tuning

When integrating Alluxio with BOS, you can optimize performance by adjusting the following configurations:

* `alluxio.underfs.bos.connection.max`: Controls the max connection number with BOS. Default value is 1024.
* `alluxio.underfs.bos.io.threads.num`: Controls the IO thread with BOS. Default value is 256.
* `alluxio.underfs.bos.socket.timeout`: Controls the socket timeout with BOS. Default value is 50 seconds.
* `alluxio.underfs.bos.connect.timeout`： Controls the connection timeout with BOS. Default value is 50 seconds.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://documentation.alluxio.io/ee-ai-en/ai-3.8-15.1.x/ufs/bos.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
