I have been using compojure-api
to build a server and I have an endpoint that returns json to the client. Now the problem: it seems to me that it is taking too much time to build the response to send back to the client.
Here is my log. It shows that the entire procedure seems to go pretty fast, but to get back to the client, takes around 8 minutes on 4 cpu thinkpad. On a second run, I saved the json to see the size and it was 12k. Is this a big json and it is justified to take this long for the server to respond? I feel like it is not and most likely I am doing something wrong.
21:21:20.978 [qtp1190836072-15] INFO capacity.capacity - lets go!
21:21:20.996 [qtp1190836072-15] INFO capacity.capacity - finished big parts
21:21:22.590 [qtp1190836072-15] INFO capacity.capacity - finished everything
21:21:22.590 [qtp1190836072-15] INFO api-stuff.handler - ready to go class clojure.lang.PersistentArrayMap
Unfortunatly, I can not show the repo, but here I try to show some configurations of my router:
(def formats
(m/create
(-> m/default-options
(m/install muuntaja.format.msgpack/format)
;; return byte[] for NIO servers
(assoc :return :bytes))))
(def app
(-> (api
{
:formats formats
:coercion nil
:swagger
{:ui "/"
:spec "/swagger.json"
:format {:formats []}
:data {:info {:title "Hopeffully a good example"
:description "API that may describe what I need"}
:tags [{:name "api", :description "some apis"}]
:consumes ["application/json"]
:produces ["application/json" "text/csv"]}}}
(context "/health" []
:tags ["health check"]
health-check ;; a get method for health check
)
(route-middleware [[hard-auth]]
(context "/download" []
:tags ["validation"]
downloads ;; routes defined
))
(route-middleware [[basic-auth-mw]]
(context "/" []
:tags ["api"]
routes ;; routes defined that has my slow return
)))))
A few things that I tried to change:
- change the format of the response (json and msgpack)
- I tried to use the default value of
:coercion
(without the key) andnil
,
But these changes did not seem to make difference.