EzDevInfo.com

web-applications interview questions

Top web-applications frequently asked interview questions

Max parallel http connections in a browser?

I am creating some suspended connections to an http server (comet, reverse ajax, etc). It works ok, but I see the browser only allows two suspended connections to a given domain simultaneously. So if a user is looking at my web app in Tab1 of their browser, then also tries loading it in Tab2, they've used up the two allowed connections to my site.

I think I can do some wildcard domain thing, where I have my http server resolve any address to my site like:

*.mysite.com/webapp  -> 123.456.789.1 (the actual ip of my server)

so:

a.mysite.com/webapp
b.mysite.com/webapp
c.mysite.com/webapp

all still point to (www.mysite.com/webapp) but the browser considers them different domains, so I don't run into the 2 connection limit. Is this true?

Even if that is true - is there any limit to the number of active connections per browser, across all domains? Say I use the scheme above - does firefox for example only allow 24 parallel connections at any given time? Something like:

1) a.mysite.com/webapp
2) www.download.com/hugefile.zip
3) b.mysite.com/webapp
4) c.mysite.com/webapp
...
24) x.mysite.com/webapp
25) // Error - all 24 possible connections currently in use!

I just picked 24 connections/firefox as an example.


Source: (StackOverflow)

What is Rack middleware?

What is Rack middleware in Ruby? I couldn't find any good explanation for what they mean by "middleware".


Source: (StackOverflow)

Advertisements

getResourceAsStream() vs FileInputStream

I was trying to load a file in a webapp, and I was getting a FileNotFound exception when I used FileInputStream. However, using the same path, I was able to load the file when I did getResourceAsStream(). What is the difference between the two methods, and why does one work while the other doesn't?


Source: (StackOverflow)

Handler "ExtensionlessUrlHandler-Integrated-4.0" has a bad module "ManagedPipelineHandler" in its module list

To be honest, I've tried to turn a dirty trick on IIS and just when I thought that I was going to get away with it, I realized my workaround doesn't work. Here's what I've tried to do:

1) I have ASP.NET application which has Preloader class that inherits IProcessHostPreloadClient and does all the heavy initialization in Preload method implementation (application is complex and it's a part of an enormous system, so it requires approximately 2 minutes to establish connections to all necessary services and pre-instantiate some Unity registrations).

2) I have a lot of work that needs to be done on application shutdown (unsubscribing, disconnecting, disposing,...), and I guess the best place to do it is in *Application_End* method located in Global.asax.

3) Everything works just fine when I have user activity (first request after the Application Pool that contains aforementioned web application is started will cause *Application_Start* to be called and afterwards *Application_End* is called on Application Pool stop or recycle), but problems occur when there is no user activity and application tries to restart itself after being active for 48 hours (configured requirement). Since there was no requests, application officially didn't get started. Ergo, it can't be gracefully stopped since *Application_End* won't be called.

4) Now comes the messy part... I've tried to make a GET request from code at the end of the Preload method, and it worked. But this solution seemed bad to me, even though it worked. So, I've tried a lot of things, and the last thing I tried was this:

SimpleWorkerRequest swr = new SimpleWorkerRequest(string.Empty, string.Empty, tw);
HttpRuntime.ProcessRequest(swr);

... and that has done it's purpose. *Application_Start* was called, (I've checked response, it was containing login page that was supposed to be displayed in initial request) and on Application Pool shutdown application ended gracefully by doing necessary work in *Application_End*.

BUT

After the application was started (preloaded and initiated) in this manner, this is what happened when I wanted to reach application via Web browser:

HTTP Error 500.21 - Internal Server Error Handler "ExtensionlessUrlHandler-Integrated-4.0" has a bad module "ManagedPipelineHandler" in its module list

I am unable to figure this out. Can anybody tell me why this happens and how to fix it?

If I don't figure this out, I will go back to first solution (sending GET request from code) but this problem will bug me since I don't even have an idea what's wrong.


Source: (StackOverflow)

External VS2013 build error "error MSB4019: The imported project was not found"

I am building a project through the command line and not inside Visual Studio 2013. Note, I had upgraded my project from Visual Studio 2012 to 2013. The project builds fine inside the IDE. Also, I completely uninstalled VS2012 first, rebooted, and installed VS2013. The only version of Visual Studio that I have is 2013 Ultimate.

ValidateProjects:
    39>path_to_project.csproj(245,3): error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
    39>Done Building Project "path_to_project.csproj" (Clean target(s)) -- FAILED.

Here are the two lines in question:

<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v12.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />

The original second line was v10.0, but I manually changed that to v12.0.

$(VSToolsPath) elongates from what I see to the v11.0 (VS2012) folder, which obviously is not there anymore. The path should have been to v12.0.

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\WebApplications\

I tried specifying VSToolsPath in my system environment variables table, but the external build utility still uses v11.0. I tried searching through the registry and that came up with nothing.

Sadly, I do not see any easy way to get the exact command line used. I use a build tool.

Thoughts?


Source: (StackOverflow)

Performing a Stress Test on Web Application?

In the past, I used Microsoft Web Application Stress Tool and Pylot to stress test web applications. I'd written a simple home page, login script, and site walkthrough (in an ecommerce site adding a few items to a cart and checkout).

Just hitting the homepage hard with a handful of developers would almost always locate a major problem. More scalability problems would surface at the second stage, and even more - after the launch.

The URL of the tools I used were Microsoft Homer (aka Microsoft Web Application Stress Tool) and Pylot.

The reports generated by these tools never made much sense to me, and I would spend many hours trying to figure out what kind of concurrent load the site would be able to support. It was always worth it because the stupidest bugs and bottlenecks would always come up (for instance, web server misconfigurations).

What have you done, what tools have you used, and what success have you had with your approach? The part that is most interesting to me is coming up with some kind of a meaningful formula for calculating the number of concurrent users an app can support from the numbers reported by the stress test application.


Source: (StackOverflow)

Difference between MEAN.js and MEAN.io

I wanted to use the MEAN JavaScript Stack, but I noticed that there are two different stacks with either their own website and installation methods: mean.js and mean.io. So I came up asking myself this question: "Which one do I use?".

So in order to answer this question I ask the community if you could explain what are the differences between these two? And if possible pros and cons? Because they look very similar to me.


Source: (StackOverflow)

Django - Set Up A Scheduled Job?

I've been working on a web app using Django, and I'm curious if there is a way to schedule a job to run periodically.

Basically I just want to run through the database and make some calculations/updates on an automatic, regular basis, but I can't seem to find any documentation on doing this.

Does anyone know how to set this up?

To clarify: I know I can set up a cron job to do this, but I'm curious if there is some feature in Django that provides this functionality. I'd like people to be able to deploy this app themselves without having to do much config (preferably zero).

I've considered triggering these actions "retroactively" by simply checking if a job should have been run since the last time a request was sent to the site, but I'm hoping for something a bit cleaner.


Source: (StackOverflow)

How popular is C++ for making websites/web applications? [closed]

I don't know why this question is bugging me, but time after time I come back to the thought - why not make websites in C++? So far I know of none (except a rumor about Yahoo). Most use PHP, Java or ASP.NET. Some are built on Ruby or Python, but even those are minorities.

At the same time, looking at StackOverflow, it seems that C++ is still a very popular language with many projects written in it. Why not for webpages?

So - what do you know about this subject? Are there any websites written in C++? Are there any frameworks/libraries that help doing this? Have YOU ever done it? If yes, did you run into any fundamental problems and would you recommend this to others?


Source: (StackOverflow)

Does Django scale?

I'm building a web application with Django. The reasons I chose Django were:

  • I wanted to work with free/open-source tools.
  • I like Python and feel it's a "long term" language, whereas regarding Ruby I wasn't sure, and PHP seemed like a huge hassle to learn.
  • I'm building a prototype for an idea and wasn't thinking too much about the future. Development speed was the main factor, and I already knew Python.
  • I knew the migration to Google App Engine would be easier should I choose to do so in the future.
  • I heard Django was "nice".

Now that I'm getting closer to thinking about publishing my work, I start being concerned about scale. The only information I found about the scaling capabilities of Django is provided by the Django team (I'm not saying anything to disregard them, but this is clearly not objective information...).

My questions:

  • What's the "largest" site that's built on Django today? (I measure size mostly by user traffic)
  • Can Django deal with 100,000 users daily, each visiting the site for a couple of hours?
  • Could a site like Stack Overflow run on Django?

Source: (StackOverflow)

How do I decide when to use Node.js? [closed]

I am new to this kind of stuff, but lately I've been hearing a lot about how good Node.js is. Considering how much I love working with jQuery and JavaScript in general, I can't help but wonder how to decide when to use Node.js. The web application I have in mind is something like Bitly - takes some content, archives it.

From all the homework I have been doing in the last few days, I obtained the following information. Node.js

  • is a command-line tool that can be run as a regular web server and lets one run JavaScript programs
  • utilizes the great V8 JavaScript engine
  • is very good when you need to do several things at the same time
  • is event-based so all the wonderful Ajax-like stuff can be done on the server side
  • lets us share code between the browser and the backend
  • lets us talk with MySQL

Some of the sources that I have come across are:

Considering that Node.js can be run almost out-of-the-box on Amazon's EC2 instances, I am trying to understand what type of problems require Node.js as opposed to any of the mighty kings out there like PHP, Python and Ruby. I understand that it really depends on the expertise one has on a language, but my question falls more into the general category of: When to use a particular framework and what type of problems is it particularly suited for?


Source: (StackOverflow)

What browsers support HTML5 WebSocket API?

I am going to develop an instant messaging application that runs in the browser.

What browsers support the WebSocket API?


Source: (StackOverflow)

Difference between the 'controller', 'link' and 'compile' functions when defining a directive

Some places seem to use the controller function for directive logic and other use link. The tabs example on the angular homepage uses controller for one and link for other directive. What is the difference between two?


Source: (StackOverflow)

Create a file in memory for user to download, not through server

Is there any way I can create a text file on the client side and prompt the user to download it, without any interaction with the server? I know I can't write directly to their machine (security and all), but can I create and prompt them to save it?


Source: (StackOverflow)

Memcached vs. Redis?

We're using a Ruby web-app with Redis server for caching. Is there is a point to test Memcached instead?

What will give me better performance? Any pros or cons between Redis and Memcached?

Points to consider:

  • Read/write speed.
  • Memory usage.
  • Disk I/O dumping.
  • Scaling.

Source: (StackOverflow)