| 1 |
<!DOCTYPE html> |
| 2 |
<html><head> |
| 3 |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 4 |
<meta http-equiv="content-type" content="text/html; charset=UTF-8"> |
| 5 |
<link href="sqlite.css" rel="stylesheet"> |
| 6 |
<title>SQLite Is Serverless</title> |
| 7 |
<!-- path= --> |
| 8 |
</head> |
| 9 |
<body> |
| 10 |
<div class=nosearch> |
| 11 |
<a href="index.html"> |
| 12 |
<img class="logo" src="images/sqlite370_banner.svg" alt="SQLite" border="0"> |
| 13 |
</a> |
| 14 |
<div><!-- IE hack to prevent disappearing logo --></div> |
| 15 |
<div class="tagline desktoponly"> |
| 16 |
Small. Fast. Reliable.<br>Choose any three. |
| 17 |
</div> |
| 18 |
<div class="menu mainmenu"> |
| 19 |
<ul> |
| 20 |
<li><a href="index.html">Home</a> |
| 21 |
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a> |
| 22 |
<li class='wideonly'><a href='about.html'>About</a> |
| 23 |
<li class='desktoponly'><a href="docs.html">Documentation</a> |
| 24 |
<li class='desktoponly'><a href="download.html">Download</a> |
| 25 |
<li class='wideonly'><a href='copyright.html'>License</a> |
| 26 |
<li class='desktoponly'><a href="support.html">Support</a> |
| 27 |
<li class='desktoponly'><a href="prosupport.html">Purchase</a> |
| 28 |
<li class='search' id='search_menubutton'> |
| 29 |
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a> |
| 30 |
</ul> |
| 31 |
</div> |
| 32 |
<div class="menu submenu" id="submenu"> |
| 33 |
<ul> |
| 34 |
<li><a href='about.html'>About</a> |
| 35 |
<li><a href='docs.html'>Documentation</a> |
| 36 |
<li><a href='download.html'>Download</a> |
| 37 |
<li><a href='support.html'>Support</a> |
| 38 |
<li><a href='prosupport.html'>Purchase</a> |
| 39 |
</ul> |
| 40 |
</div> |
| 41 |
<div class="searchmenu" id="searchmenu"> |
| 42 |
<form method="GET" action="search"> |
| 43 |
<select name="s" id="searchtype"> |
| 44 |
<option value="d">Search Documentation</option> |
| 45 |
<option value="c">Search Changelog</option> |
| 46 |
</select> |
| 47 |
<input type="text" name="q" id="searchbox" value=""> |
| 48 |
<input type="submit" value="Go"> |
| 49 |
</form> |
| 50 |
</div> |
| 51 |
</div> |
| 52 |
<script> |
| 53 |
function toggle_div(nm) { |
| 54 |
var w = document.getElementById(nm); |
| 55 |
if( w.style.display=="block" ){ |
| 56 |
w.style.display = "none"; |
| 57 |
}else{ |
| 58 |
w.style.display = "block"; |
| 59 |
} |
| 60 |
} |
| 61 |
function toggle_search() { |
| 62 |
var w = document.getElementById("searchmenu"); |
| 63 |
if( w.style.display=="block" ){ |
| 64 |
w.style.display = "none"; |
| 65 |
} else { |
| 66 |
w.style.display = "block"; |
| 67 |
setTimeout(function(){ |
| 68 |
document.getElementById("searchbox").focus() |
| 69 |
}, 30); |
| 70 |
} |
| 71 |
} |
| 72 |
function div_off(nm){document.getElementById(nm).style.display="none";} |
| 73 |
window.onbeforeunload = function(e){div_off("submenu");} |
| 74 |
/* Disable the Search feature if we are not operating from CGI, since */ |
| 75 |
/* Search is accomplished using CGI and will not work without it. */ |
| 76 |
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){ |
| 77 |
document.getElementById("search_menubutton").style.display = "none"; |
| 78 |
} |
| 79 |
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */ |
| 80 |
function hideorshow(btn,obj){ |
| 81 |
var x = document.getElementById(obj); |
| 82 |
var b = document.getElementById(btn); |
| 83 |
if( x.style.display!='none' ){ |
| 84 |
x.style.display = 'none'; |
| 85 |
b.innerHTML='show'; |
| 86 |
}else{ |
| 87 |
x.style.display = ''; |
| 88 |
b.innerHTML='hide'; |
| 89 |
} |
| 90 |
return false; |
| 91 |
} |
| 92 |
var antiRobot = 0; |
| 93 |
function antiRobotGo(){ |
| 94 |
if( antiRobot!=3 ) return; |
| 95 |
antiRobot = 7; |
| 96 |
var j = document.getElementById("mtimelink"); |
| 97 |
if(j && j.hasAttribute("data-href")) j.href=j.getAttribute("data-href"); |
| 98 |
} |
| 99 |
function antiRobotDefense(){ |
| 100 |
document.body.onmousedown=function(){ |
| 101 |
antiRobot |= 2; |
| 102 |
antiRobotGo(); |
| 103 |
document.body.onmousedown=null; |
| 104 |
} |
| 105 |
document.body.onmousemove=function(){ |
| 106 |
antiRobot |= 2; |
| 107 |
antiRobotGo(); |
| 108 |
document.body.onmousemove=null; |
| 109 |
} |
| 110 |
setTimeout(function(){ |
| 111 |
antiRobot |= 1; |
| 112 |
antiRobotGo(); |
| 113 |
}, 100) |
| 114 |
antiRobotGo(); |
| 115 |
} |
| 116 |
antiRobotDefense(); |
| 117 |
</script> |
| 118 |
<div class=fancy> |
| 119 |
<div class=nosearch> |
| 120 |
<div class="fancy_title"> |
| 121 |
SQLite Is Serverless |
| 122 |
</div> |
| 123 |
</div> |
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
<h1 id="sqlite_is_serverless"><span>1. </span>SQLite Is Serverless</h1> |
| 130 |
|
| 131 |
<p> |
| 132 |
Most SQL database engines are implemented as a separate server process. |
| 133 |
Programs that want to access the database communicate with the server |
| 134 |
using some kind of interprocess communication (typically TCP/IP) to send |
| 135 |
requests to the server and to receive back results. |
| 136 |
SQLite does not work this way. |
| 137 |
With SQLite, the process that wants to access the database reads and |
| 138 |
writes directly from the database files on disk. |
| 139 |
There is no intermediary server process. |
| 140 |
</p> |
| 141 |
|
| 142 |
<p> |
| 143 |
There are advantages and disadvantages to being serverless. |
| 144 |
The main advantage is that there is no separate server process |
| 145 |
to install, setup, configure, initialize, manage, and troubleshoot. |
| 146 |
This is one reason why SQLite is a |
| 147 |
"<a href="zeroconf.html">zero-configuration</a>" database engine. |
| 148 |
Programs that use SQLite require no administrative support for |
| 149 |
setting up the database engine before they are run. |
| 150 |
Any program that is able to access the disk is able to use an SQLite database. |
| 151 |
</p> |
| 152 |
|
| 153 |
<p> |
| 154 |
On the other hand, a database engine that uses a server can |
| 155 |
provide better protection from bugs in the client |
| 156 |
application - stray pointers in a client cannot corrupt memory |
| 157 |
on the server. |
| 158 |
And because a server is a single persistent process, |
| 159 |
it is able to control database access with more precision, |
| 160 |
allowing for finer-grained locking and better concurrency. |
| 161 |
</p> |
| 162 |
|
| 163 |
<p> |
| 164 |
Most SQL database engines are client/server based. |
| 165 |
Of those that are serverless, SQLite is the only one |
| 166 |
known to this author that allows multiple applications |
| 167 |
to access the same database at the same time. |
| 168 |
</p> |
| 169 |
|
| 170 |
<h1 id="classic_serverless_vs_neo_serverless"><span>2. </span>Classic Serverless Vs. Neo-Serverless</h1> |
| 171 |
|
| 172 |
<p> |
| 173 |
<i>(This section was added on 2018-04-02)</i> |
| 174 |
|
| 175 |
</p><p> |
| 176 |
Recently, folks have begun to use the |
| 177 |
word "serverless" to mean something subtly different from its intended |
| 178 |
meaning in this document. Here are two possible definitions of "serverless": |
| 179 |
|
| 180 |
</p><ol> |
| 181 |
<li><p> |
| 182 |
<b>Classic Serverless:</b> |
| 183 |
The database engine runs within the same process, thread, and address space |
| 184 |
as the application. There is no message passing or network activity. |
| 185 |
|
| 186 |
</p></li><li><p> |
| 187 |
<b>Neo-Serverless:</b> |
| 188 |
The database engine runs in a separate namespace from the application, |
| 189 |
probably on a separate machine, but the database is provided as a |
| 190 |
turn-key service by the hosting provider, requires no management or |
| 191 |
administration by the application owners, and is so easy to use |
| 192 |
that the developers can think of the database as being serverless |
| 193 |
even if it really does use a server under the covers. |
| 194 |
</p></li></ol> |
| 195 |
|
| 196 |
<p> |
| 197 |
SQLite is an example of a classic serverless database engine. |
| 198 |
With SQLite, there are no other processes, threads, machines, or |
| 199 |
other mechanisms (apart from host computer OS and filesystem) |
| 200 |
to help provide database services or implementation. There really |
| 201 |
is no server. |
| 202 |
|
| 203 |
</p><p> |
| 204 |
<a href="https://docs.microsoft.com/en-us/azure/cosmos-db/serverless-computing-database">Microsoft Azure Cosmos DB</a> |
| 205 |
and |
| 206 |
<a href="https://aws.amazon.com/s3/">Amazon S3</a> |
| 207 |
are examples of a neo-serverless databases. |
| 208 |
These databases are implemented by server processes running separately |
| 209 |
in the cloud. |
| 210 |
But the servers are maintained and administered by the ISP, not by |
| 211 |
the application developer. |
| 212 |
Application developers just use the service. Developers do not have to |
| 213 |
provision, configure, or manage database server instances, as all of that |
| 214 |
work is handled automatically by the service provider. Database servers |
| 215 |
do in fact exist, they are just hidden from the developers. |
| 216 |
|
| 217 |
</p><p> |
| 218 |
It is important to understand these two different definitions for |
| 219 |
"serverless". |
| 220 |
When a database claims to be "serverless", |
| 221 |
be sure to discern whether they mean "classic serverless" |
| 222 |
or "neo-serverless". |
| 223 |
</p><p align="center"><small><i>This page was last updated on 2025-06-12 09:10:23Z </small></i></p> |
| 224 |
|