ruma / homeserver

A Matrix homeserver written in Rust.
https://www.ruma.io/
1.08k stars 41 forks source link

Add gzip compression to SerializableResponse #139

Closed jstnlef closed 7 years ago

jstnlef commented 7 years ago

No reason for us to waste extra bandwidth right? ;)

jimmycuadra commented 7 years ago

Good idea! It think we should make it an iron::AfterMiddleware instead of a modifier so that we can apply it to all HTTP responses.

jstnlef commented 7 years ago

That was my thought at first but then I figured that perhaps it makes more sense to apply as a modifier to responses with actual results rather than everything. But then again, we'll likely want error responses gzipped as well. I can rework it sometime tomorrow.

mujx commented 7 years ago

Of course gzip and other optimizations could be made by a reverse proxy when running ruma.

jimmycuadra commented 7 years ago

Hmm, that's true. I wonder how much of that type of functionality Ruma should handle itself and how much we should explicitly not support, suggesting instead that the user run a reverse proxy. It's already the case that Ruma expects a reverse proxy to be used for TLS.

mujx commented 7 years ago

It's much easier to throw a nginx config that implements this kind of functionality than to implement and maintain it in ruma.

From my point of view, ruma should be concerned only with the implementation of the Matrix protocol.

Since a reverse proxy would be mandatory for running ruma (unless there is a better option) we can create the appropriate configs as part of the suggested deployment setup.

jimmycuadra commented 7 years ago

I think mujx is right. I'm gonna close this, but thank you for the work, jstnlef!

jstnlef commented 7 years ago

While I can appreciate this decision, I was unaware that Ruma required a reverse proxy to run "properly". I was under the impression that one of the major benefits of using Rust as the implementation language of a matrix homeserver was to allow it to run as a standalone service without the need for more complex service topologies. e.g. standing up nginx in front of it.

mujx commented 7 years ago

It's not that complex really, but a standard setup for most web services.

Services like nginx provide a lot of features out of the box through configuration and it wouldn't be wise to reinvent the wheel. (e.g. compression is basically one line, gzip on).

jstnlef commented 7 years ago

Lol "complex" in that 2 of anything is inherently more complex than 1 :P. I understand the benefits of nginx and have used it in production a few times before. I hardly believe this is "reinventing the wheel" though. It's common for standalone web services to provide this functionality (configurable of course) out of the box. For example, Synapse provides both TLS support and compression in app. That being said, since that service is a python web service, it would actually benefit much more from using nginx than ruma would. Either way, just my 2 cents.

jstnlef commented 7 years ago

I sort of view nginx as a power saw when a pocket knife would do.