|
| 1 | +# Go feature server |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +The Go feature server is an HTTP/gRPC endpoint that serves features. |
| 6 | +It is written in Go, and is therefore significantly faster than the Python feature server. |
| 7 | +See this [blog post](https://feast.dev/blog/go-feature-server-benchmarks/) for more details on the comparison between Python and Go. |
| 8 | +In general, we recommend the Go feature server for all production use cases that require extremely low-latency feature serving. |
| 9 | +Currently only the Redis and SQLite online stores are supported. |
| 10 | + |
| 11 | +## CLI |
| 12 | + |
| 13 | +By default, the Go feature server is turned off. |
| 14 | +To turn it on you can add `go_feature_serving: True` to your `feature_store.yaml`: |
| 15 | + |
| 16 | +{% code title="feature_store.yaml" %} |
| 17 | +```yaml |
| 18 | +project: my_feature_repo |
| 19 | +registry: data/registry.db |
| 20 | +provider: local |
| 21 | +online_store: |
| 22 | + type: redis |
| 23 | + connection_string: "localhost:6379" |
| 24 | +go_feature_serving: True |
| 25 | +``` |
| 26 | +{% endcode %} |
| 27 | +
|
| 28 | +Then the `feast serve` CLI command will start the Go feature server. |
| 29 | +As with Python, the Go feature server uses port 6566 by default; the port be overridden with a `--port` flag. |
| 30 | +Moreover, the server uses HTTP by default, but can be set to use gRPC with `--type=grpc`. |
| 31 | + |
| 32 | +Alternatively, if you wish to experiment with the Go feature server instead of permanently turning it on, you can just run `feast serve --go`. |
| 33 | + |
| 34 | +## Installation |
| 35 | + |
| 36 | +The Go component comes pre-compiled when you install Feast with Python versions 3.8-3.10 on macOS or Linux (on x86). |
| 37 | +In order to install the additional Python dependencies, you should install Feast with |
| 38 | +``` |
| 39 | +pip install feast[go] |
| 40 | +``` |
| 41 | +You must also install the Apache Arrow C++ libraries. |
| 42 | +This is because the Go feature server uses the cgo memory allocator from the Apache Arrow C++ library for interoperability between Go and Python, to prevent memory from being accidentally garbage collected when executing on-demand feature views. |
| 43 | +You can read more about the usage of the cgo memory allocator in these [docs](https://pkg.go.dev/github.com/apache/arrow/go/arrow@v0.0.0-20211112161151-bc219186db40/cdata#ExportArrowRecordBatch). |
| 44 | +
|
| 45 | +For macOS, run `brew install apache-arrow`. |
| 46 | +For linux users, you have to install `libarrow-dev`. |
| 47 | +``` |
| 48 | +sudo apt update |
| 49 | +sudo apt install -y -V ca-certificates lsb-release wget |
| 50 | +wget https://apache.jfrog.io/artifactory/arrow/$(lsb_release --id --short | tr 'A-Z' 'a-z')/apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb |
| 51 | +sudo apt install -y -V ./apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb |
| 52 | +sudo apt update |
| 53 | +sudo apt install -y -V libarrow-dev # For C++ |
| 54 | +``` |
| 55 | +For developers, if you want to build from source, run `make compile-go-lib` to build and compile the go server. In order to build the go binaries, you will need to install the `apache-arrow` c++ libraries. |
| 56 | +
|
| 57 | +## Alpha features |
| 58 | +
|
| 59 | +### Feature logging |
| 60 | +
|
| 61 | +The Go feature server can log all requested entities and served features to a configured destination inside an offline store. |
| 62 | +This allows users to create new datasets from features served online. Those datasets could be used for future trainings or for |
| 63 | +feature validations. To enable feature logging we need to edit `feature_store.yaml`: |
| 64 | +```yaml |
| 65 | +project: my_feature_repo |
| 66 | +registry: data/registry.db |
| 67 | +provider: local |
| 68 | +online_store: |
| 69 | + type: redis |
| 70 | + connection_string: "localhost:6379" |
| 71 | +go_feature_serving: True |
| 72 | +feature_server: |
| 73 | + feature_logging: |
| 74 | + enabled: True |
| 75 | +``` |
| 76 | + |
| 77 | +Feature logging configuration in `feature_store.yaml` also allows to tweak some low-level parameters to achieve the best performance: |
| 78 | +```yaml |
| 79 | +feature_server: |
| 80 | + feature_logging: |
| 81 | + enabled: True |
| 82 | + flush_interval_secs: 300 |
| 83 | + write_to_disk_interval_secs: 30 |
| 84 | + emit_timeout_micro_secs: 10000 |
| 85 | + queue_capacity: 10000 |
| 86 | +``` |
| 87 | +All these parameters are optional. |
| 88 | +
|
| 89 | +### Python SDK retrieval |
| 90 | +
|
| 91 | +The logic for the Go feature server can also be used to retrieve features during a Python `get_online_features` call. |
| 92 | +To enable this behavior, you must add `go_feature_retrieval: True` to your `feature_store.yaml`. |
| 93 | +You must also have all the dependencies installed as detailed above. |
0 commit comments