# Do i need a webserver with datomic cloud for a typical web application?

**URL:** <https://forum.datomic.com/t/do-i-need-a-webserver-with-datomic-cloud-for-a-typical-web-application/1840>\
**Category:** Datomic Cloud\
**Created:** [April 26, 2021, 1:33am UTC](https://forum.datomic.com/t/do-i-need-a-webserver-with-datomic-cloud-for-a-typical-web-application/1840 "2021-04-26T01:33:07Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![drewverlee](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.datomic.com/drewverlee/32/308_2.png) [@drewverlee](https://forum.datomic.com/u/drewverlee)\
**Post date:** [April 26, 2021, 1:33am UTC](https://forum.datomic.com/t/do-i-need-a-webserver-with-datomic-cloud-for-a-typical-web-application/1840/1 "2021-04-26T01:33:07Z")

</div>

Given a solo topology setup, is it recommended to also run a web server? As i understand it the Ion \> AWS lambda would be handling everything i would need a server for:

- opening network socket,
- listening for requests
- calling the handler

Though, now that I’m typing this, I’m not sure it would be isolating requests in their own thread.

Assuming they do overlap, which I’m still obviously thinking through, what would be the recommendation for local development then? Understandable, that’s mostly up to me, but i’m curious what others have done. My current idea would be to run the web server locally.

---

<div class="post-metadata">

**Author:** ![jamesd3142](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.datomic.com/jamesd3142/32/435_2.png) [@jamesd3142](https://forum.datomic.com/u/jamesd3142)\
**Post date:** [April 26, 2021, 12:25pm UTC](https://forum.datomic.com/t/do-i-need-a-webserver-with-datomic-cloud-for-a-typical-web-application/1840/2 "2021-04-26T12:25:47Z")

</div>

I’m developing a Clojurescript app at the moment with just Datomic Cloud Ions, API Gateway and Cognito for auth. Early days yet but I don’t see where I will need a server. The app assets (HTML, CSS, JS etc) are served by CloudFront+S3. There were a few tricks to get API Gateway hooked up so let me know if you get stuck.

---

<div class="post-metadata">

**Author:** ![jplane](https://avatars.discourse-cdn.com/v4/letter/j/d78d45/32.png) [@jplane](https://forum.datomic.com/u/jplane)\
**Post date:** [April 26, 2021, 4:54pm UTC](https://forum.datomic.com/t/do-i-need-a-webserver-with-datomic-cloud-for-a-typical-web-application/1840/3 "2021-04-26T16:54:56Z")

</div>

Hey friends, have a look at this pedestal sample for inspiration.

> **[pedestal/pedestal-ions-sample](https://github.com/pedestal/pedestal-ions-sample)**
>
> A sample app demonstrating the usage of pedestal.ions

It was written before dev-local but should work fine with that too.

Also, when you outgrow lambdas, it should also work with http-direct.

---

<div class="post-metadata">

**Author:** ![drewverlee](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.datomic.com/drewverlee/32/308_2.png) [@drewverlee](https://forum.datomic.com/u/drewverlee)\
**Post date:** [April 26, 2021, 5:09pm UTC](https://forum.datomic.com/t/do-i-need-a-webserver-with-datomic-cloud-for-a-typical-web-application/1840/4 "2021-04-26T17:09:58Z")

</div>

Thanks James if you have anything written up on your setup (cloudfront+s3) i would love to take a look. I’m using Rum and so the initial load of the html/JS might need to be handled in the lambda. Though i suppose I can cache any static load page in s3.

---

<div class="post-metadata">

**Author:** ![drewverlee](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.datomic.com/drewverlee/32/308_2.png) [@drewverlee](https://forum.datomic.com/u/drewverlee)\
**Post date:** [April 26, 2021, 5:10pm UTC](https://forum.datomic.com/t/do-i-need-a-webserver-with-datomic-cloud-for-a-typical-web-application/1840/5 "2021-04-26T17:10:20Z")

</div>

Thanks Jplane, i’ll take a look. I can use all the examples I can get.

---

<div class="post-metadata">

**Author:** ![jzwolak](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.datomic.com/jzwolak/32/450_2.png) [@jzwolak](https://forum.datomic.com/u/jzwolak)\
**Post date:** [April 28, 2021, 1:12pm UTC](https://forum.datomic.com/t/do-i-need-a-webserver-with-datomic-cloud-for-a-typical-web-application/1840/6 "2021-04-28T13:12:14Z")

</div>

No, you do not need a webserver with datomic cloud. You may use AWS API Gateway and I believe that is the recommended way to do things. It’s what I did when following the documentation. [Ions Tutorial | Datomic](https://docs.datomic.com/cloud/ions/ions-tutorial.html)

Also, the pedestal sample referenced earlier uses Pedestal Ions, which has a nice 1-2-3-4 steps laid out on the GitHub page at [GitHub - pedestal/pedestal.ions: A Pedestal Interceptor Chain provider for Datomic Ions](https://github.com/pedestal/pedestal.ions). I found this useful and modeled it directly in my code.

Last, I did setup a dev server - this took me a while to figure out how to do - using dev-local’s `divert-system` and pedestal’s builtin webserver `io.pedestal.http/start`. However, I found that this wasn’t necessary for most of my local development. I could just call my functions directly from the repl. With dev-local, the datomic queries can be tested like this and many http requests can be tested since they are plain old data going to pure functions! It gave me a little mind blowing moment. I suggest trying how much you can develop and test without starting up a dev server. I’m coming from worlds like RoR, Flask, and other places where this would be impossible, so my mind went straight to “setup a dev web server”. Only after struggling with this for a while did I realize… “I don’t need a dev web server to test what I’m wanting to test. Perhaps that’s why this doesn’t exist right out of the box.”

Of course, there is still value in seeing what the final app looks like with everything together.

---

<div class="post-metadata">

**Author:** ![hkrishnan2005](https://avatars.discourse-cdn.com/v4/letter/h/65b543/32.png) [@hkrishnan2005](https://forum.datomic.com/u/hkrishnan2005)\
**Post date:** [April 18, 2022, 7:22am UTC](https://forum.datomic.com/t/do-i-need-a-webserver-with-datomic-cloud-for-a-typical-web-application/1840/7 "2022-04-18T07:22:07Z")

</div>

Hello Jason, Thank you for the write-up regarding dev-local. Question on dev-local’s `divert-system` and pedestal’s builtin webserver `io.pedestal.http/start` . Could you provide some details? I keep getting a .lock error and am not able to run both nRepl & Jetty Server with dev-local. Any information is much appreciated. Thanks in advance.

---

<div class="post-metadata">

**Author:** ![jzwolak](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.datomic.com/jzwolak/32/450_2.png) [@jzwolak](https://forum.datomic.com/u/jzwolak)\
**Post date:** [April 18, 2022, 11:39am UTC](https://forum.datomic.com/t/do-i-need-a-webserver-with-datomic-cloud-for-a-typical-web-application/1840/8 "2022-04-18T11:39:03Z")

</div>

Hi Krishnan, it would take me some digging to figure out what I did. That was over a year ago. Datomic’s dev-local `divert-system` should be Google-able. If you’re getting lock errors related to file based locks then I would do the standard debugging of lock files - shutdown all programs, delete the lock files, start the services back up one at a time, note which program gives the error and why (port conflict, starting a service twice, etc.). I hope this helps some. Sorry I can’t be of more help. I don’t want to spend an hour digging through my old project figuring out what I did.

---

<div class="post-metadata">

**Author:** ![hkrishnan2005](https://avatars.discourse-cdn.com/v4/letter/h/65b543/32.png) [@hkrishnan2005](https://forum.datomic.com/u/hkrishnan2005)\
**Post date:** [April 18, 2022, 8:53pm UTC](https://forum.datomic.com/t/do-i-need-a-webserver-with-datomic-cloud-for-a-typical-web-application/1840/9 "2022-04-18T20:53:19Z")

</div>

Hi Jason, Thank you for the response and the hints. I have done all of the items you mentioned, but no luck yet. Pedestal/Jetty or the nRepl, whichever is started first locks the storage location. Therefore, the Cursive/nRepl or the Jetty server won’t work at the same time with dev-local. Maybe some changes in deps.edn or logging, I don’t know yet.

Thanks again.

---

<div class="post-metadata">

**Author:** ![jzwolak](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.datomic.com/jzwolak/32/450_2.png) [@jzwolak](https://forum.datomic.com/u/jzwolak)\
**Post date:** [April 19, 2022, 11:53am UTC](https://forum.datomic.com/t/do-i-need-a-webserver-with-datomic-cloud-for-a-typical-web-application/1840/10 "2022-04-19T11:53:31Z")

</div>

Ok, yeah, it sounds like the commands you’re running are starting two instances of Clojure where both of them are using dev-local with the same file for local storage. That’s not possible. It seems like what you’re trying to do is have one instance run a local web server (Jetty with Pedestal and dev-local) and another instance with a REPL so you can type Clojure code. Am I right? If that’s so, know that the second instance - the one with the REPL - doesn’t need to load your program. It just needs to connect to the remote REPL server started by the first instance.

Try this:

1. Run Pedestal/Jetty with a REPL server and dev-local.
2. Connect to that REPL server with `clj` but without loading all your code (and therefore, without starting dev-local a second time).

You can then run code against the first instance, load code, etc… I don’t recall off the top of my head how to connect to a remote REPL from the command line. You’ll have to look that up, but I know it isn’t necessary to load your code to do it.

---

<div class="post-metadata">

**Author:** ![jzwolak](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.datomic.com/jzwolak/32/450_2.png) [@jzwolak](https://forum.datomic.com/u/jzwolak)\
**Post date:** [April 19, 2022, 12:02pm UTC](https://forum.datomic.com/t/do-i-need-a-webserver-with-datomic-cloud-for-a-typical-web-application/1840/11 "2022-04-19T12:02:43Z")

</div>

Try this for connecting to the nrepl: [nREPL Clients :: nREPL](https://nrepl.org/nrepl/usage/clients.html)  
Of course you also need to be sure the first instance starts the nrepl server properly. That’s a one liner. Something like `(defonce server (start-server :bind "172.18.0.5" :port 4001))` See [nREPL Server :: nREPL](https://nrepl.org/nrepl/usage/server.html)

---

<div class="post-metadata">

**Author:** ![hkrishnan2005](https://avatars.discourse-cdn.com/v4/letter/h/65b543/32.png) [@hkrishnan2005](https://forum.datomic.com/u/hkrishnan2005)\
**Post date:** [April 19, 2022, 11:32pm UTC](https://forum.datomic.com/t/do-i-need-a-webserver-with-datomic-cloud-for-a-typical-web-application/1840/12 "2022-04-19T23:32:47Z")

</div>

Hi Jason,

Thank you for the clear explanation. It worked! This is what I did.

First, started the Jetty sever (am using Pedestal) → clj -M:dev:jetty  
Then, → (require '[nrepl.server :refer [start-server stop-server]])  
Then, → (defonce server (start-server :port 54400))  
Then, → (require '[XXXX.server :as server])  
Then, → (def XXXX-service (server/run-dev 9091))

My Cursive repl is configured to access 54400! Hope this will help someone looking for a fix.

Thanks again to Jason for the information.
