# Application Package Reference

This is the application package reference. An application package is the deployment unit in Vespa. To deploy an application, create an application package and vespa-deploy or use the deploy API. The application package is a directory of files and subdirectories:

Directory/fileDescriptionRequired
[application]/ The top level directory is the name of the application Yes
[application]/services.xml Describes which services to run where, and their main configuration Yes
[application]/validation-overrides.xml Override, allowing this package to deploy even if it fails validation No
[application]/models/ Machine-learned models in the application package. Refer to stateless model evaluation, Tensorflow, Onnx and XGBoost, also see deploying remote models No
[application]/searchdefinitions/ Contains the *.sd files describing the document types of the application and how they should be searched No
[application]/components/ Contains *.jar files containing searcher(s) for the JDisc Container. No
[application]/rules/ Contains *.sr files containing rule bases for semantic recognition and translation of the query No
[application]/search/ Search chains config No
[application]/constants/ Constant tensors No
[application]/ext/ Files that are guaranteed to be ignored by Vespa (i.e. they will be excluded when processing the application package and cannot be referenced from any other place in the application package) No
[application]/hosts.xml The mapping from logical nodes to actual hosts No

Additional files and directories can be placed anywhere in the application package. These will be not be processed explicitly by Vespa when deploying the application package (i.e., they will only be considered if they are referred to from within the application package), but there is no guarantee to how these might be processed in a future release. To extend the application package in a way that is guaranteed to be ignored by Vespa in all future releases, use the [application]/ext/ directory.

An application package can be zipped for deployment - both of these are supported (here the application package is in the application directory):

$zip -r ../app.zip .$ zip -r app.zip application

Use whatever name for the zip file - then refer to the file instead of the path in deploy commands - example. Note: Using tar / gzip is not supported.

## Deploy

upload Uploads an application package to the config server. Normally not used, as prepare includes upload Verifies that a configuration server is up and running Uploads the application to the configuration server, which stores it in $VESPA_HOME/var/db/vespa/config_server/serverdb/tenants/[tenant]/sessions/[sessionid]. [sessionid] increases for each prepare-call. [tenant] is default in a single-tenant system. The config server also stores the application in a ZooKeeper instance at /config/v2/tenants/default/sessions/[sessionid] - this distributes the application to all config servers Creates metadata about the deployed the applications package (which user deployed it, which directory was it deployed from and at what time was it deployed) and stores it in ...sessions/[sessionid]/.applicationMetaData Verifies that the application package contains the required files and performs a consistency check Validates the xml config files using the schema, found in$VESPA_HOME/share/vespa/schema Checks if there are config changes between the active application and this prepared application that require actions like restart or re-feed (like changes to search definitions). These actions are returned as part of the prepare step in the deployment API. This prevents breaking changes to production - also read about validation overrides Distributes constant tensors and bundles with components to nodes using file-distribution. Files are downloaded to $VESPA_HOME/var/db/vespa/filedistribution URL download starts, downloading to$VESPA_HOME/var/db/vespa/download Waits for prepare to complete Activates new configuration version Signals to containers to load new bundles - read more in container components Use fetch to download the active application package

## Versioning application packages

An application can be given a user-defined version, available at /ApplicationStatus. Configure the version in services.xml (at top level):

<services>
<config name="container.handler.observability.application-userdata">
<version>42</version>
</config>
...
</services>


## Preprocess directives

Use preprocess directives to:

• preprocess:properties: define properties that one can refer to everywhere in services.xml
• preprocess:include: split services.xml in smaller chunks
Below, ${container.port} is replaced by 4099. The contents of content.xml is placed at the include point. This is applied recursively, one can use preprocess directives in included files, as long as namespaces are defined in the top level file: <services version="1.0" xmlns:preprocess="properties"> <preprocess:properties> <container.port>4099</container.port> </preprocess:properties> <container version="1.0"> <http> <server id="container" port="${container.port}" />
</http>
<search />
</container>
<preprocess:include file="content.xml" />
</services>

Sample content.xml:
<content version="1.0" >
<redundancy>1</redundancy>
<documents>
<document type="music.sd" mode="index" />
</documents>
<nodes>
<node hostalias="node0"/>
<node hostalias="node1"/>
<node hostalias="node2"/>
</nodes>

</content>