milvus-logo
LFAI
Home
  • Get Started

Get Started with Milvus Lite

This guide describes how to install, configure, and use Milvus Lite.

Do not use Milvus Lite in any production environment or if you require high performance. For production purposes, consider using Milvus clusters or fully-managed Milvus on Zilliz Cloud.

Overview

Milvus Lite is a lightweight version of Milvus that works seamlessly with Google Colab and Jupyter Notebook.

Thanks to the ability of Milvus standalone to run with embedded etcd and local storage, Milvus Lite comes with a single binary with no other dependencies that you can easily install and run on your machine, or embed in any of your Python applications.

Anything you do with Milvus Lite, and any code you write for Milvus Lite can be safely migrated to Milvus instances installed in other ways.

It also comes with a CLI-based Milvus standalone server to run on your machine. Embedding it into your Python code or using it as a standalone server is up to your choice.

Application scenarios

Milvus Lite is suitable for the following scenarios:

  • You want to use Milvus directly without having it installed using Milvus Operator, Helm, or Docker Compose etc.
  • You do not want to launch any virtual machines or containers while you are using Milvus.
  • You want to embed Milvus features in your Python applications.

Prerequisites

  • Python 3.7 or later

  • Verified operating systems are as follows:

    • Ubuntu >= 20.04 (x86_64)
    • CentOS >= 7.0 (x86_64)
    • MacOS >= 11.0 (Apple Silicon)
  • For Linux users, Milvus Lite uses manylinux2014 as the base image. It should be able to run on most Linux distributions.
  • Milvus Lite can also run on Windows. However, this is not strictly verified.

Install Milvus Lite

Milvus Lite is available on PyPI, you can install it via pip.

$ python3 -m pip install milvus

Or, install it with PyMilvus as follows:

$ python3 -m pip install milvus[client]

Get started

You can download the example notebook from the example folder of our project repository to get started.

Use Milvus Lite

You can import Milvus Lite as a Python library or use it as a CLI-based Milvus standalone server to run on your machine.

Start Milvus Lite

  • To start Milvus Lite as a Python module, do as follows:

    from milvus import default_server
    from pymilvus import connections, utility
    
    # (OPTIONAL) Set if you want store all related data to specific location
    # Default location:
    #   %APPDATA%/milvus-io/milvus-server on windows
    #   ~/.milvus-io/milvus-server on linux
    # default_server.set_base_dir('milvus_data')
    
    # (OPTIONAL) if you want cleanup previous data
    # default_server.cleanup()
    
    # Start your milvus server
    default_server.start()
    
    # Now you could connect with localhost and the given port
    # Port is defined by default_server.listen_port
    connections.connect(host='127.0.0.1', port=default_server.listen_port)
    
    # Check if the server is ready.
    print(utility.get_server_version())
    
    # Stop your milvus server
    default_server.stop()
    

    You can also use the with statement to have Milvus Lite automatically stop when you do not need it.

    from milvus import default_server
    
    with default_server:
      # Milvus Lite has already started, use default_server here.
      connections.connect(host='127.0.0.1', port=default_server.listen_port)
    
  • To start Milvus Lite as a CLI-based standalone server, run

    $ milvus-server
    

    Then you can use PyMilvus or other ways that suit you to connect to the standalone server.

Start Milvus Lite in debug mode

  • To run Milvus Lite in debug mode as a Python Module, do as follows:

    from milvus import debug_server, MilvusServer
    
    debug_server.run()
    
    # Or you can create a MilvusServer by yourself
    # server = MilvusServer(debug=True)
    
  • To run the standalone server in debug mode, do as follows:

    $ milvus-server --debug
    

Persist data and logs

  • To set a local directory for Milvus Lite to store all related data and logs in a local directory, do as follows:

    from milvus import default_server
    
    with default_server:
      default_server.set_base_dir('milvus_data')
    
  • To persist all data and logs generated by the standalone server on your local drive, run

    $ milvus-server --data milvus_data
    

Configure Milvus Lite

You can configure Milvus Lite in the same way as you do Milvus instances through both Python APIs and CLI.

  • To configure Milvus Lite using Python APIs, you can use the config.set API of a MilvusServer instance for both basic and extra configuration items as follows:

    from milvus import default_server
    
    with default_server:
      default_server.config.set('system_Log_level', 'info')
      default_server.config.set('proxy_port', 19531)
      default_server.config.set('dataCoord.segment.maxSize', 1024)
    
  • To configure Milvus Lite using CLI, run the following for basic configurations.

    $ milvus-server --system-log-level info
    $ milvus-server --proxy-port 19531
    

    Or, run the following for extra configurations.

    $ milvus-server --extra-config dataCoord.segment.maxSize=1024
    

You can find all configurable configuration items in config.yaml template shipped with the Milvus package. You can also find the template in our project repository.

What's next

If you have new ideas and want to contribute to Milvus Lite, please read the Contributing Guide first.

If you encounter any problems when installing or using Milvus Lite, file an issue here.