A simple scenario. User logs in through the form baked by some high level framework (rails let's say) and starts chatting. Chat is erlang-written and only authenticated users can participate in. That means, every request (containing some session id) comming from client side needs to be verified (authenticated) inside erlang code somehow. Obviously erlang knows nothing about logged users and needs to ask framework for this information.
The question is how to design the communication between erlang and framework to not cause additional bottlenecks开发者_C百科?
I was thinking about storing session ids in erlang as well. but additional effort related with synchronization (when new users log in) and session timeouts causes headache.
There is nothing like free lunch in this case. If you will keep authentication authority outside erlang you would have to deal with all this headache. You can provide some caching inside erlang to improve speed but it will be bottleneck and also you have to deal with all cache coherency issues. IMHO best solution is make erlang authentication authority and provide authentication for high level framework.
If we are talking about Rails, I believe it is possible to connect to the same database from Erlang and retrieve session data from sessions table (provided you are using db as session storage). You can even pass data to Rails this way.
精彩评论