Chapter 4. Running the VoltDB Example Applications

Besides the Hello World application, VoltDB comes with four example applications that demonstrate the capabilities and performance of VoltDB. The example applications include:

  • Voltcache — demonstrates how to use VoltDB as an in-memory cache. Caches, such as memcached, are a popular technique to provide rapid access to the most frequently used content from a larger, slower database. They improve performance on read access to popular content. However, caches do little to improve write performance. Using VoltDB as a cache provides improvement to both read and write performance, while adding transactional consistency and durability.

  • Voltkv — demonstrates how to create a Key-Value Store using VoltDB. Key-Value Stores are popular for web applications because of their simplicity, performance, and scalability. Using VoltDB to create a Key-Value Store adds transactions, durability, and automatic partitioning without sacrificing the other characteristics.

  • Voter — simulates a telephone voting application, similar to what you might find associated with a TV talent show or other popularity contest. The Voter application comes with client applications written to several alternate VoltDB interfaces, including JDBC and JSON.

  • JSON Sessions — demonstrates how to create a flexible schema through use of JSON-encoded VARCHAR columns and the JSON FIELD() function. The JSON sessions application simulates user tracking, where logins from multiple sites are tracked in a single user session table. All sessions have common fields such as username and global session id. At the same time, session-specific data is stored in a single VARCHAR column as JSON data.

The example applications are packaged with the software. After installing VoltDB, you can find the examples in the examples folder. For instance, if you install VoltDB in the folder /opt/voltdb, the examples are in the folder /opt/voltdb/examples. If you install VoltDB locally in your account's $HOME directory, the examples are in the folder $HOME/voltdb-n.n.nn/examples where n.n.nn is the version number of VoltDB.

All examples include a shell script (run.sh) for building and running the server and a client in the default configuration. Additionally, each example folder contains a README that provides specifics about the application, configuration options, and how to run that application.

4.1. Building and Running the Example Applications

The examples come with a shell script to automate the building and running of the application. To build an example, set default to the subdirectory for that example and execute the run.sh script using the argument catalog. For example, the following commands build the voter example, assuming you start from the examples folder:

$ cd voter
$ ./run.sh catalog

Once you build the example, you can run it using the script argument server and client. Note that there are two separate processes that you need to run. Start the server process first, using the ./run.sh server command, then open a new terminal window and use the ./run.sh client command to start the client application.

The server, as its name implies, acts as the database server. The client performs the application logic and displays any messages appropriate to the application. (Note that using the shell script without an argument both compiles the application catalog and starts the server.)