I am trying to prototype a small web application to see if I can use Phoenix and Elixir to build some intranet web applications for use by my co-workers at my company. We've been a typical Microsoft .NET shop forever, but I'm interested in playing with some other technologies, with Elixir and Phoenix being two of them.
I have a virtual machine running Windows 10
and IIS 8
. I installed HttpPlatformHandler on the VM as well to run the Phoenix application and pass requests to it from IIS (there's a reason for this, which I'll get to in a moment).
When I run my Phoenix app standalone on Windows, it runs great. I don't see any issues. When I run my Phoenix app using HttpPlatformHandler
and IIS, I see the erl.exe process constantly running and consuming about 35-40% of the CPU (I'm running with 2 cores and 8GB RAM on the VM). I also see the memory constantly growing without stopping. After a couple of minutes, it will blow past 1GB and move on its way to 2GB (I'm watching memory usage using Process Explorer). There's no load or active requests on the Phoenix app. This happens in both dev and prod environments.
I want to run Phoenix behind IIS because it's an intranet application and it will be running on a Windows domain and most of the users will be Windows users. I created a plug that will read the Windows user token from the X-IIS-WindowsAuthToken
HTTP header that HttpPlatformHandler
adds to the requests that it forwards to the Phoenix process, and I'm using a set of NIFS to call the Windows API to get the Windows SID and domain\username of the authenticated user in order to establish the session and authorize the user.
Has anyone tried this before and seeing the same issue? I'm relatively new to Elixir and Phoenix debugging and would love some hints on what I can do to try to figure out why the Erlang runtime is doing this, or how to determine if it's something that I'm doing in my code.
I'm not sure that it's me, because I see this happening on a plain Phoenix application that is freshly generated using mix phoenix.new
.
For reference, here's my web.config
for my Phoenix application:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpplatformhandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
</handlers>
<httpPlatform processPath="C:\Projects\neucode\run.bat"
arguments=""
stdoutLogEnabled="true"
forwardWindowsAuthToken="true">
<environmentVariables>
<environmentVariable name="MIX_ENV" value="prod"/>
</environmentVariables>
</httpPlatform>
</system.webServer>
</configuration>
My run.bat
file:
mix phoenix.server
I greatly appreciate any assistance or suggestions that anyone can provide. Please let me know if there's anything else that I can provide that would be helpful in diagnosing the problem.
Thank you in advance.
UPDATE
I figured out how to connect to my Phoenix application running in IIS using Observer thanks to this gist. It looks like the problem process is the user process:
I started tracing on this process and the port that it is linked to and I see a continual stream of what I am guessing are receive events with empty data:
I'm guessing from looking around that this is the kernel user process. Does anyone know how I can figure out what that port is and why it's sending a continual stream of events?